Coder Social home page Coder Social logo

Comments (7)

panva avatar panva commented on May 18, 2024

respond with the status code inside the body

that's not it. i can see the JSON body :-( weird, you're also NOT doing and openid connect request, clearly you don't include the openid scope.

from node-openid-client.

panva avatar panva commented on May 18, 2024
  1. discovered Issuer using Issuer.discover('https://passport.twitch.tv').then((issuer) => { ... })
  2. set up a new client using new issuer.Client({ client_id, client_secret, redirect_uris: [...], token_endpoint_auth_method: 'client_secret_post' });
  3. did an authorization request and response using the documented methods.
  4. I am getting a valid token set and validating it too.
TokenSet {
  id_token: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjEifQ.eyJzdWIiOiIxMjUyMzQ4NTIiLCJpc3MiOiJodHRwczovL2FwaS50d2l0Y2gudHYvYXBpIiwiYXVkIjoidnA1dnJpMTdjOWY5YTc0eGlteXNhcHgyem43amVxIiwiZXhwIjoxNTA1NDIwNTY4LCJpYXQiOjE1MDU0MTk2Njh9.WP5EDO4u9DeW3Xi7cSJZrY9UxhXdZb9pjB0FENlHyHqWbzyuFQBKSOwXGdWC-6Tk5TJ2jX_ad--H5wRLcQSYO-aKUPIkQvDEre4dFNSvK_VR-HOU2HgNjJMHLYcdKjnue0hOtDn5e-fu9TwLlaQdryBEZ3YMsBW4kkaSfSFA3IDqCiYeLl6yF7ZnuCFmXxj19iU6dRdA2Hlg8AynymGm60XTrSlDW8w3IoQ6WuAphZZxvL8QRKsr_WoNRryOu2CfW8V0851R-mHCnhjqFd-VoBDUhJrsplbeqVA0MQwKaC26zcsbyvdxfRg3doCv2cZs85WRv880tl2vire_tZ1fuQ',
  refresh_token: '...',
  access_token: '...',
  scope: 'openid',
  expires_at: 1505434085 }

from node-openid-client.

panva avatar panva commented on May 18, 2024

can you paste your server code?

from node-openid-client.

andystevensname avatar andystevensname commented on May 18, 2024

Thanks for getting back to me, I set my client up manually:

const twitchIssuer = new Issuer({
  issuer: 'https://api.twitch.tv',
  authorization_endpoint: 'https://api.twitch.tv/kraken/oauth2/authorize',
  token_endpoint: 'https://api.twitch.tv/api/oauth2/token',
  userinfo_endpoint: 'https://api.twitch.tv/kraken/user',
  jwks_uri: 'https://api.twitch.tv/api/oidc/keys'
});

const twitchClient = new twitchIssuer.Client({
  client_id: ... ,
  client_secret: ... ,
  token_endpoint_auth_method: 'client_secret_post'
});

const twitchParams = {
  redirect_uri: protocol + '//' + callbackHost + callbackPort + '/auth/twitch/callback',
  scope: 'user_read user_follows_edit channel_check_subscription chat_login'
};

const passReqToCallback = true;

passport.use('twitchOIDC', new OIDCStrategy({ client: twitchClient, params: twitchParams, passReqToCallback: passReqToCallback }, (req, tokenset, userinfo, done) => {
  console.log('tokenset', tokenset);
  console.log('access_token', tokenset.access_token);
  console.log('id_token', tokenset.id_token);
  console.log('claims', tokenset.claims);
  console.log('userinfo', userinfo);
 
  // I don't have this in my code, I'm just interested in seeing the console output right now before incorporating the user model.
  /*
  models.User.findOne({ id: tokenset.claims.sub }, function (err, user) {
    if (err) return done(err);
    return done(null, user);
  });*/

  return done(err);

}));

from node-openid-client.

panva avatar panva commented on May 18, 2024

this is likely your problem

  userinfo_endpoint: 'https://api.twitch.tv/kraken/user',

this is not where userinfo is, also you issuer identifier is incorrect to what twitch uses. just use discovery as in my example instead of setting up the issuer on your own. https://passport.twitch.tv/.well-known/openid-configuration

from node-openid-client.

panva avatar panva commented on May 18, 2024

not to mention that the userinfo endpoint twitch has does not work as it should according to the specification.

  1. remove userinfo from your callback arguments
  2. add openid to your list of requested scopes
  3. discover issuer

you will get your tokens then using this library

from node-openid-client.

andystevensname avatar andystevensname commented on May 18, 2024

Thank you for your help, I managed to receive a token using the discovery method without implementing the 'userinfo' argument.

from node-openid-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.