Skip to content

Commit 9553f5c

Browse files
elsonpi0
authored andcommitted
feat(oauth2): support access_type=offline to enable refresh tokens from google (#303)
1 parent ba09118 commit 9553f5c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

docs/schemes/oauth2.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ auth: {
2020
authorization_endpoint: 'https://accounts.google.com/o/oauth2/auth',
2121
userinfo_endpoint: 'https://www.googleapis.com/oauth2/v3/userinfo',
2222
scope: ['openid', 'profile', 'email'],
23+
access_type: undefined,
24+
access_token_endpoint: undefined,
2325
response_type: 'token',
2426
token_type: 'Bearer',
2527
redirect_uri: undefined,
@@ -49,6 +51,14 @@ If a `false` value is set, we only do login without fetching user profile.
4951

5052
By default is `token`. If you use `code` you may have to implement a server side logic to sign the response code.
5153

54+
### `access_type`
55+
56+
If using Google code authorization flow (`response_type: 'code'`) set to `offline` to ensure a refresh token is returned in the initial login request. (See [Google documentation](https://developers.google.com/identity/protocols/OpenIDConnect#refresh-tokens))
57+
58+
### `access_token_endpoint`
59+
60+
If using Google code authorization flow (`response_type: 'code'`) provide a URI for a service that accepts a POST request with JSON payload containing a `code` property, and returns tokens [exchanged by provider](https://developers.google.com/identity/protocols/OpenIDConnect#exchangecode) for `code`. See [source code](https://github.com/nuxt-community/auth-module/blob/dev/lib/schemes/oauth2.js)
61+
5262
### `token_type`
5363

5464
By default is `Bearer`. It will be used in `Authorization` header of axios requests.

lib/schemes/oauth2.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export default class Oauth2Scheme {
6868
const opts = {
6969
protocol: 'oauth2',
7070
response_type: this.options.response_type,
71+
access_type: this.options.access_type,
7172
client_id: this.options.client_id,
7273
redirect_uri: this._redirectURI,
7374
scope: this._scope,

0 commit comments

Comments
 (0)