Skip to content

Commit 66169fc

Browse files
authored
fix: way to get accesstoken and deprecated option (#173)
* fix: way to get accesstoken * fix: deprecated option
1 parent dabc31e commit 66169fc

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

examples/google.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fastify.get('/login/google/callback', function (request, reply) {
3131
url: 'https://www.googleapis.com/oauth2/v2/userinfo',
3232
method: 'GET',
3333
headers: {
34-
Authorization: 'Bearer ' + result.access_token
34+
Authorization: 'Bearer ' + result.token.access_token
3535
},
3636
json: true
3737
}, function (err, res, data) {

examples/spotify.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@ fastify.register(oauthPlugin, {
1818
})
1919

2020
fastify.get('/login/spotify/callback', async (req, reply) => {
21-
const token = await fastify.Spotify.getAccessTokenFromAuthorizationCodeFlow(req)
21+
const result = await fastify.Spotify.getAccessTokenFromAuthorizationCodeFlow(req)
2222

23-
req.log.info('The Spotify token is %o', token)
24-
reply.send({ access_token: token.access_token })
23+
req.log.info('The Spotify token is %o', result.token)
24+
reply.send({ access_token: result.token.access_token })
2525
})
2626

27-
fastify.listen(process.env.PORT, (err) => {
28-
if (err) {
29-
fastify.log.error(err)
30-
process.exit(1)
31-
}
32-
})
27+
fastify.listen({ port: process.env.PORT })

0 commit comments

Comments
 (0)