Skip to content

Commit 0d60c2d

Browse files
rchlpi0
authored andcommitted
feat(oauth2): support passing extra query params (#358)
1 parent 8654a48 commit 0d60c2d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

docs/schemes/oauth2.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@ auth: {
2626
```
2727

2828
```js
29-
this.$auth.loginWith('social')
29+
this.$auth.loginWith('social', options)
3030
```
3131

32+
`options` is an optional object with `params` property defining additional URL parameters to pass to authorization endpoint. For example:
33+
34+
```js
35+
this.$auth.loginWith('social', { params: { lang: 'en' } })
36+
```
37+
38+
will add extra query parameter `&lang=en` to a URL.
39+
3240
### `authorization_endpoint`
3341

3442
**REQUIRED** - Endpoint to start login flow. Depends on oauth service.

lib/schemes/oauth2.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default class Oauth2Scheme {
6363
return this.$auth.reset()
6464
}
6565

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

7879
if (this.options.audience) {

0 commit comments

Comments
 (0)