Skip to content

Commit ebb60a5

Browse files
committed
fixed to use userinfo not deprecated API
1 parent e8c371b commit ebb60a5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

complete-application/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ app.get('/login', (req, res, next) => {
100100
res.redirect(302, '/');
101101
}
102102

103-
res.redirect(302, `${fusionAuthURL}/oauth2/authorize?client_id=${clientId}&response_type=code&redirect_uri=http://localhost:${port}/oauth-redirect&state=${userSessionCookie?.stateValue}&code_challenge=${userSessionCookie?.challenge}&code_challenge_method=S256`)
103+
res.redirect(302, `${fusionAuthURL}/oauth2/authorize?scope=email%20profile%20openid&client_id=${clientId}&response_type=code&redirect_uri=http://localhost:${port}/oauth-redirect&state=${userSessionCookie?.stateValue}&code_challenge=${userSessionCookie?.challenge}&code_challenge_method=S256`)
104104
});
105105
//end::login[]
106106

@@ -134,12 +134,13 @@ app.get('/oauth-redirect', async (req, res, next) => {
134134
res.cookie(userToken, accessToken, { httpOnly: true })
135135

136136
// Exchange Access Token for User
137-
const userResponse = (await client.retrieveUserUsingJWT(accessToken.access_token)).response;
138-
if (!userResponse?.user) {
139-
console.error('Failed to get User from access token, redirecting home.');
137+
const userResponse = (await client.retrieveUserInfoFromAccessToken(accessToken.access_token)).response;
138+
console.log(userResponse);
139+
if (!userResponse) {
140+
console.error('Failed to get User info from access token, redirecting home.');
140141
res.redirect(302, '/');
141142
}
142-
res.cookie(userDetails, userResponse.user);
143+
res.cookie(userDetails, userResponse);
143144

144145
res.redirect(302, '/account');
145146
} catch (err: any) {

0 commit comments

Comments
 (0)