Reputation: 29
I am stuck at finding values of authorizationURL:,tokenURL: for aws cognito passportjs auth flow.It would be helpful if I get such snippet .Trying to fetch the profile , phone and other details from aws cognito ui in the backend application.
passport.use(new OAuth2Strategy({
authorizationURL: 'https://www.example.com/oauth2/authorize',
tokenURL: 'https://www.example.com/oauth2/token',
clientID: EXAMPLE_CLIENT_ID,
clientSecret: EXAMPLE_CLIENT_SECRET,
callbackURL: "http://localhost:3000/auth/example/callback"
},
function(accessToken, refreshToken, profile, cb) {
User.findOrCreate({ exampleId: profile.id }, function (err, user) {
return cb(err, user);
});
}
));
Upvotes: 1
Views: 1752
Reputation: 531
The values for the tokenURL and authorizationURL are found in the Cognito settings in the AWS Console User Pool and Cognito documentation.
You can obtain the domain name from the Cognito config in the AWS Console under Cognito->User Pools->App Integration->Domain Name and tack on the endpoints from the documentation as follows. For example:
authorizationURL: 'https://your-domain-prefix.auth.us-east-1.amazoncognito.com/oauth2/authorize',
tokenURL: 'https://your-domain-prefix.auth.us-east-1.amazoncognito.com/oauth2/token',
Amazon AWS Documentation for Cognito Endpoints https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html
Passport Documentation: http://www.passportjs.org/docs/oauth/
Upvotes: 2