Skip to content

Commit

Permalink
feat(oauth2): support passing extra query params (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl authored and pi0 committed May 23, 2019
1 parent 8654a48 commit 0d60c2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion docs/schemes/oauth2.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ auth: {
```

```js
this.$auth.loginWith('social')
this.$auth.loginWith('social', options)
```

`options` is an optional object with `params` property defining additional URL parameters to pass to authorization endpoint. For example:

```js
this.$auth.loginWith('social', { params: { lang: 'en' } })
```

will add extra query parameter `&lang=en` to a URL.

### `authorization_endpoint`

**REQUIRED** - Endpoint to start login flow. Depends on oauth service.
Expand Down
3 changes: 2 additions & 1 deletion lib/schemes/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class Oauth2Scheme {
return this.$auth.reset()
}

login () {
login ({ params } = {}) {
const opts = {
protocol: 'oauth2',
response_type: this.options.response_type,
Expand All @@ -73,6 +73,7 @@ export default class Oauth2Scheme {
// Note: The primary reason for using the state parameter is to mitigate CSRF attacks.
// @see: https://auth0.com/docs/protocols/oauth2/oauth-state
state: this.options.state || randomString(),
...params,
};

if (this.options.audience) {
Expand Down

0 comments on commit 0d60c2d

Please sign in to comment.