Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(oauth2): support passing extra query params #358

Merged
merged 1 commit into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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