Help needed with Microsoft Authorization for Custom Microsoft Pack

Hey there. I’m new to pack building. I’ve been able to practice building a few packs that connect to external APIs. One that is giving me a hard time is the microsoft graph api authentication. I used the sample microsoft API setup code and passed in my client id and secret. However, when I try to authenticate in a doc, I get the below error. What am I missing here?

Authorization failed

5 mins ago

Overview: Authorization failed

code is required but is either missing or invalid
User ID
Pack Version
Pack ID
Request ID
Created at
Aug 4, 2022 @ 07:15:07

Here is the code I used:

  type: coda.AuthenticationType.OAuth2,
  tokenUrl: "",

  // eslint-disable-next-line max-len
  // Learn more:
  scopes: [

  // Additional parameters to ensure a refresh_token is returned.
  additionalParams: {
    prompt: "consent",

  // Enable PKCE (optional but recommended).
  useProofKeyForCodeExchange: true,

  // Determines the display name of the connected account.
  getConnectionName: async function (context) {
    let response = await context.fetcher.fetch({
      method: "GET",
      url: "",
    let user = response.body;
    return user.displayName;

// Allow the pack to make requests to Microsoft.

The error

code is required but is either missing or invalid

means that the OAuth provider, when redirecting back to Coda, didn’t include an authorization code, but instead returned an error. Unfortunately we currently don’t expose what that error is in the logs, which makes it difficult to troubleshoot.

Check to make sure that for each scope you request in you also add that scope to your Microsoft app’s settings:


Thanks, Eric. Unfortunately, I received the same error when I included the scopes. Any other suggestions?

I was able to figure it out. The client secret is based on the value not the secret id. Thanks for your help.