Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
fix: respect scopes join character (#9)
Browse files Browse the repository at this point in the history
* fix: respect scopes join character

* do not encode `+` symbol
  • Loading branch information
boywithkeyboard authored Jul 12, 2023
1 parent 82bf7ed commit b52817d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 2 additions & 4 deletions createAuthorizeUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export function createAuthorizeUrl<
// deno-lint-ignore no-explicit-any
) as any

opts.scopes = (opts.scopes as string[]).join(preset.scopeJoinCharacter)

opts.scope = opts.scopes
opts.scope = (opts.scopes as string[]).join(preset.scopeJoinCharacter ?? ' ')

delete opts.scopes

Expand Down Expand Up @@ -74,5 +72,5 @@ export function createAuthorizeUrl<
}),
).toString()

return `${preset.authorizeUri}?${qs}`
return `${preset.authorizeUri}?${qs}`.replaceAll('%2B', '+')
}
5 changes: 4 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"fmt": {
"semiColons": false,
"singleQuote": true
"singleQuote": true,
"exclude": [
"./changelog.md"
]
},
"tasks": {
"build:types": "cd ./out && npx -p typescript tsc --target esnext --module es2020 --declaration --emitDeclarationOnly --outDir types --newLine lf mod.ts",
Expand Down
8 changes: 8 additions & 0 deletions presets/Google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ export const Google = createPreset<
tokenUri: 'oauth2.googleapis.com/token',
userUri: 'www.googleapis.com/oauth2/v2/userinfo',

scopeJoinCharacter: '+',

queryParameters: {
authorizeEndpoint: {
include_granted_scopes: true,
},
},

scopes: [
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
Expand Down

0 comments on commit b52817d

Please sign in to comment.