Skip to content

Instantly share code, notes, and snippets.

@amemiya
amemiya / TwitterOauthService.ts
Created December 28, 2022 12:45
Extended OAuth2User in twitter-api-sdk to allow external injection of codeVerifier and codeChallenge.
import {OAuth2User, OAuth2UserOptions} from "twitter-api-sdk/dist/OAuth2User.js";
export default class TwitterOauthService extends OAuth2User {
#options: OAuth2UserOptions
#code_verifier?: string
#code_challenge?: string
/**
* Modified so that codeVerifier and codeChallenge can be set in the constructor.
* Also, codeVerifier and codeChallenge need to be saved in cookies etc., so I made a getter.