auth0 / custom-social-connections

http://auth0.github.io/custom-oauth2-dashboard
MIT License
29 stars 30 forks source link

DOMAIN/login/callback Does not fetch a token #36

Closed SamuelBradley closed 5 years ago

SamuelBradley commented 5 years ago

I'm having an issue with the callbacks when the connection I am trying to implement calls

https://MY-DOMAIN/login/callback?code=CODE&state=STATE (GET method)

It redirects to https://manage.auth0.com/tester/callback?connection=AAF&error=invalid_request&error_description=access_token%20is%20not%20defined Without attempting to excahnge the code for a token (I am using the connection tester). Am I doing something wrong?

SamuelBradley commented 5 years ago

Nevermind it was my user profile rule that was breaking it for those that are interested this is how to do it for OIDC conformant providers

function(access_token, ctx, callback) {
  var jwt = require("jsonwebtoken");
  const idToken = jwt.decode(ctx.id_token);
  const profile = {
    "user_id": idToken.sub,
    "name": idToken.name,
    "given_name": idToken.given_name,
    "family_name": idToken.family_name,
    "middle_name": idToken.middle_name,
    "nickname": idToken.nickname,
    "preferred_username": idToken.preferred_username,
    "profile": idToken.profile,
    "picture": idToken.picture,
    "website": idToken.website,
    "email": idToken.email,
    "email_verified": idToken.email_verified,
    "gender": idToken.gender,
    "birthdate": idToken.birthdate,
    "zoneinfo": idToken.zoneinfo,
    "locale": idToken.locale,
    "phone_number": idToken.phone_number,
    "phone_number_verified": idToken.phone_number_verified,
    "address": idToken.address,
    "updated_at": idToken.updated_at
  };
  console.log(JSON.stringify(profile, null, 2));
  callback(null, profile);
}