Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to disable pkce flow? #37

Open
vetsinen-onlyfans opened this issue Jan 12, 2023 · 3 comments
Open

how to disable pkce flow? #37

vetsinen-onlyfans opened this issue Jan 12, 2023 · 3 comments

Comments

@vetsinen-onlyfans
Copy link

vetsinen-onlyfans commented Jan 12, 2023

I try to disable pkce usage by setting option pkce: false, but when see strategy, pkce still is ictive
my code:

const twitterStrategy =     // <2> Strategy initialization
    new Strategy(
        {
            clientID: process.env.TWITTER_CLIENT_ID,
            clientSecret: process.env.TWITTER_CLIENT_SECRET,
            clientType: 'public',
            callbackURL,
            pkce: false,
        },
        // <3> Verify callback
        (accessToken, refreshToken, profile, done) => {
            console.log('Success!', { accessToken, refreshToken });
            return done(null, profile);
        }
    )
console.dir(twitterStrategy);

but twitterStrategy is, and it seems that pkce is on

Strategy {
  name: 'twitter',
  _verify: [Function (anonymous)],
  _oauth2: {
    _clientId: 'Z3lZMlFzMHZocnIwbmtZc001Zmo6MTpjaQ',
    _clientSecret: '9E2rUQlpQKuVwKAWpnLcJb53IxjSfhQiZA9sHYwfmB4yOFya1u',
    _baseSite: '',
    _authorizeUrl: 'https://twitter.com/i/oauth2/authorize',
    _accessTokenUrl: 'https://api.twitter.com/2/oauth2/token',
    _accessTokenName: 'access_token',
    _authMethod: 'Bearer',
    _customHeaders: {
      Authorization: 'Basic WjNsWk1sRnpNSFpvY25Jd2JtdFpjMDAxWm1vNk1UcGphUTo5RTJyVVFscFFLdVZ3S0FXcG5MY0piNTNJeGpTZmhRaVpBOXNIWXdmbUI0eU9GeWExdQ=='
    },
    _useAuthorizationHeaderForGET: false,
    _agent: undefined
  },
  _callbackURL: 'http://127.0.0.1:3000/social/callback/twitter',
  _scope: undefined,
  _scopeSeparator: ' ',
  _pkceMethod: 'S256',
  _key: 'oauth:twitter',
  _stateStore: PKCESessionStore { _key: 'oauth:twitter' },
  _trustProxy: undefined,
  _passReqToCallback: undefined,
  _skipUserProfile: false,
  _userProfileURL: 'https://api.twitter.com/2/users/me?user.fields=profile_image_url,url'
}
@janhalama
Copy link
Collaborator

PKCE is required by Twitter as OAuth2 provider. You can not authenticate with disabled PKCE.

We only provide authorization code with PKCE and refresh token as the supported grant types for this initial launch. We may provide more grant types in the future.

For more information see: https://developer.twitter.com/en/docs/authentication/oauth-2-0/authorization-code

Why do you want to disable PKCE? Is there anything that I missed?

@vetsinen-onlyfans
Copy link
Author

i have app with separated frontend and backend and i try to implement twitter login. google and twitch login works ok, but there is a problem to make twitter login work, so i hoped that oauth 2 can work without pkce

PKCE is required by Twitter as OAuth2 provider. You can not authenticate with disabled PKCE.

We only provide authorization code with PKCE and refresh token as the supported grant types for this initial launch. We may provide more grant types in the future.

For more information see: https://developer.twitter.com/en/docs/authentication/oauth-2-0/authorization-code

Why do you want to disable PKCE? Is there anything that I missed?

i

@jnv
Copy link
Collaborator

jnv commented Jan 13, 2023

I suspect this issue is just another aspect of the problem you reported in #36. Twitter OAuth 2.0 requires PKCE and PKCE requires session storage (express-session), so please check if you have it configured correctly. Consider also changing the clientType to confidential, since in your case it's a server handling the authorization flow, not the client application.

If I'm not mistaken, I think Google OAuth flow can be implemented without reliance on session, but I think it requires explicitly disabling state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants