Skip to content

Commit

Permalink
feat: Add Twitter/X auth
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwertfeger committed Aug 27, 2024
1 parent 6af8fe2 commit 183468c
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ const _waspConfig: ProviderConfig = {
Authorization: `Bearer ${accessToken}`,
},
});
const providerProfile = (await response.json()) as {

const jsonResponse = await response.json();

const providerProfile = jsonResponse.data as {
id?: string;
name?: string;
username?: string;
profile_image_url?: string;
};


if (!providerProfile.id) {
throw new Error("Invalid profile");
}
Expand All @@ -53,10 +56,10 @@ const _waspConfig: ProviderConfig = {

return createOAuthProviderRouter({
provider,
oAuthType: 'OAuth2',
oAuthType: 'OAuth2WithPKCE',
userSignupFields: _waspUserSignupFields,
getAuthorizationUrl: ({ state }) => twitter.oAuthClient.createAuthorizationURL(state, config),
getProviderTokens: ({ code }) => twitter.oAuthClient.validateAuthorizationCode(code),
getAuthorizationUrl: ({ state, codeVerifier }) => twitter.oAuthClient.createAuthorizationURL(state, codeVerifier, config),
getProviderTokens: ({ code, codeVerifier }) => twitter.oAuthClient.validateAuthorizationCode(code, codeVerifier),
getProviderInfo: ({ accessToken }) => getTwitterProfile(accessToken),
});
},
Expand Down

0 comments on commit 183468c

Please sign in to comment.