Custom runtime scope for microsoft provider

Hi, im having trouble requesting additional scopes when signing a user in specifically using microsoft, my auth is configured like this

  socialProviders: {
    microsoft: {
      clientId: process.env.MICROSOFT_CLIENT_ID || "",
      clientSecret: process.env.MICROSOFT_CLIENT_SECRET || "",
      tenantId: "common",
      requireSelectAccount: true,
      disableDefaultScope: true,
      disableImplicitSignUp: true,
      disableSignUp: true,
      prompt: "consent",
    },
  },


and i have two different places where i want to either only read basic user info or also their mailbox

await authClient.signIn.social({
  provider: "microsoft",
  errorCallbackURL: "/error",
  scopes: ["openid", "profile", "email", "User.Read", "offline_access"],
});


await authClient.signIn.social({
  provider: "microsoft",
  scopes: [
    "Mail.Read",
    "Mail.Send",
    "openid",
    "profile",
    "email",
    "User.Read",
    "offline_access",
  ],
});


but using those would result in microsoft saying "scope" param is missing
7775B919-D93A-4652-B18D-B47C2795ABE7.png
Solution
GitHub
For Microsoft: Allows incremental scope expansion
For Google: Return all granted scopes to current key, so that signIn does not overwrite previously granted scopes in db
Was this page helpful?