Skip to content

Commit

Permalink
feat(oauth2): support access_type=offline to enable refresh tokens …
Browse files Browse the repository at this point in the history
…from google (#303)
  • Loading branch information
elson authored and pi0 committed Jun 13, 2019
1 parent ba09118 commit 9553f5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/schemes/oauth2.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ auth: {
authorization_endpoint: 'https://accounts.google.com/o/oauth2/auth',
userinfo_endpoint: 'https://www.googleapis.com/oauth2/v3/userinfo',
scope: ['openid', 'profile', 'email'],
access_type: undefined,
access_token_endpoint: undefined,
response_type: 'token',
token_type: 'Bearer',
redirect_uri: undefined,
Expand Down Expand Up @@ -49,6 +51,14 @@ If a `false` value is set, we only do login without fetching user profile.

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

### `access_type`

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))

### `access_token_endpoint`

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)

### `token_type`

By default is `Bearer`. It will be used in `Authorization` header of axios requests.
Expand Down
1 change: 1 addition & 0 deletions lib/schemes/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default class Oauth2Scheme {
const opts = {
protocol: 'oauth2',
response_type: this.options.response_type,
access_type: this.options.access_type,
client_id: this.options.client_id,
redirect_uri: this._redirectURI,
scope: this._scope,
Expand Down

0 comments on commit 9553f5c

Please sign in to comment.