Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 20, 2024. It is now read-only.

Commitb9567df

Browse files
committed
Preserve query string params in authorizationUri
1 parentb2f7174 commitb9567df

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

‎src/client-oauth2.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ function createUri (options, tokenType) {
161161
// Check the required parameters are set.
162162
expects(options,'clientId','authorizationUri')
163163

164-
returnoptions.authorizationUri+'?'+Querystring.stringify(Object.assign({
164+
constsep=options.authorizationUri.includes('?') ?'&' :'?'
165+
166+
returnoptions.authorizationUri+sep+Querystring.stringify(Object.assign({
165167
client_id:options.clientId,
166168
redirect_uri:options.redirectUri,
167169
scope:sanitizeScope(options.scopes),

‎test/code.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global describe, it */
1+
/* global describe, it, context */
22
varexpect=require('chai').expect
33
varconfig=require('./support/config')
44
varClientOAuth2=require('../')
@@ -24,6 +24,24 @@ describe('code', function () {
2424
'scope=notifications&response_type=code&state='
2525
)
2626
})
27+
context('when authorizationUri contains query parameters',function(){
28+
it('should preserve query string parameters',function(){
29+
constauthWithParams=newClientOAuth2({
30+
clientId:config.clientId,
31+
clientSecret:config.clientSecret,
32+
accessTokenUri:config.accessTokenUri,
33+
authorizationUri:config.authorizationUri+'?bar=qux',
34+
authorizationGrants:['code'],
35+
redirectUri:config.redirectUri,
36+
scopes:'notifications'
37+
})
38+
expect(authWithParams.code.getUri()).to.equal(
39+
config.authorizationUri+'?bar=qux&client_id=abc&'+
40+
'redirect_uri=http%3A%2F%2Fexample.com%2Fauth%2Fcallback&'+
41+
'scope=notifications&response_type=code&state='
42+
)
43+
})
44+
})
2745
})
2846

2947
describe('#getToken',function(){

‎test/token.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global describe, it */
1+
/* global describe, it, context */
22
varexpect=require('chai').expect
33
varconfig=require('./support/config')
44
varClientOAuth2=require('../')
@@ -22,6 +22,22 @@ describe('token', function () {
2222
'scope=notifications&response_type=token&state='
2323
)
2424
})
25+
context('when authorizationUri contains query parameters',function(){
26+
it('should preserve query string parameters',function(){
27+
constauthWithParams=newClientOAuth2({
28+
clientId:config.clientId,
29+
authorizationUri:config.authorizationUri+'?bar=qux',
30+
authorizationGrants:['token'],
31+
redirectUri:config.redirectUri,
32+
scopes:['notifications']
33+
})
34+
expect(authWithParams.token.getUri()).to.equal(
35+
config.authorizationUri+'?bar=qux&client_id=abc&'+
36+
'redirect_uri=http%3A%2F%2Fexample.com%2Fauth%2Fcallback&'+
37+
'scope=notifications&response_type=token&state='
38+
)
39+
})
40+
})
2541
})
2642

2743
describe('#getToken',function(){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp