Skip to content

Commit 6c5c4cd

Browse files
authored
fix(microsoft): fix duplicated scopes (#331)
1 parent 239f97a commit 6c5c4cd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/runtime/server/lib/oauth/microsoft.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,17 @@ export function defineOAuthMicrosoftEventHandler({ config, onSuccess, onError }:
7777
const redirectURL = config.redirectURL || getOAuthRedirectURL(event)
7878

7979
if (!query.code) {
80-
const scope = config.scope && config.scope.length > 0 ? config.scope : ['User.Read']
80+
config.scope = config.scope && config.scope.length > 0 ? config.scope : ['User.Read']
81+
// guarantee uniqueness of the scope
82+
config.scope = [...new Set(config.scope)]
8183
// Redirect to Microsoft Oauth page
8284
return sendRedirect(
8385
event,
8486
withQuery(authorizationURL as string, {
8587
client_id: config.clientId,
8688
response_type: 'code',
8789
redirect_uri: redirectURL,
88-
scope: scope.join(' '),
90+
scope: config.scope.join(' '),
8991
...config.authorizationParams,
9092
}),
9193
)

0 commit comments

Comments
 (0)