Skip to content

Commit

Permalink
fix(microsoft): fix duplicated scopes (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux authored Feb 4, 2025
1 parent 239f97a commit 6c5c4cd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/runtime/server/lib/oauth/microsoft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,17 @@ export function defineOAuthMicrosoftEventHandler({ config, onSuccess, onError }:
const redirectURL = config.redirectURL || getOAuthRedirectURL(event)

if (!query.code) {
const scope = config.scope && config.scope.length > 0 ? config.scope : ['User.Read']
config.scope = config.scope && config.scope.length > 0 ? config.scope : ['User.Read']
// guarantee uniqueness of the scope
config.scope = [...new Set(config.scope)]
// Redirect to Microsoft Oauth page
return sendRedirect(
event,
withQuery(authorizationURL as string, {
client_id: config.clientId,
response_type: 'code',
redirect_uri: redirectURL,
scope: scope.join(' '),
scope: config.scope.join(' '),
...config.authorizationParams,
}),
)
Expand Down

0 comments on commit 6c5c4cd

Please sign in to comment.