> ## Documentation Index
> Fetch the complete documentation index at: https://nango.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Excel

> Access the Microsoft Excel API in 2 minutes 💨

<Tabs>
  <Tab title="🚀 Quickstart">
    <Steps>
      <Step title="Create an integration">
        In Nango ([free signup](https://app.nango.dev)), go to [Integrations](https://app.nango.dev/dev/integrations) -> *Configure New Integration* -> *Microsoft Excel*.  Nango doesn't provide a test OAuth app for Microsoft Excel yet. You’ll need to set up your own by following these [instructions](#🧑%E2%80%8D💻-oauth-app-setup). After that, make sure to add the OAuth client ID, secret, and scopes in the integration settings in Nango.
      </Step>

      <Step title="Authorize Microsoft Excel">
        Go to [Connections](https://app.nango.dev/dev/connections) -> *Add Test Connection* -> *Authorize*, then log in to Microsoft Excel. Later, you'll let your users do the same directly from your app.
      </Step>

      <Step title="Call the Microsoft Excel API">
        Let's make your first request to the Microsoft Excel (Microsoft Graph) API (fetch worksheets from a specific workbook). Replace the placeholders below with your [secret key](https://app.nango.dev/dev/environment-settings), [integration ID](https://app.nango.dev/dev/integrations), [connection ID](https://app.nango.dev/dev/connections), and a workbook file ID:

        <Tabs>
          <Tab title="cURL">
            ```bash theme={null}
            curl "https://api.nango.dev/proxy/v1.0/me/drive/items/{fileId}/workbook/worksheets" \
              -H "Authorization: Bearer <NANGO-SECRET-KEY>" \
              -H "Provider-Config-Key: <INTEGRATION-ID>" \
              -H "Connection-Id: <CONNECTION-ID>"
            ```
          </Tab>

          <Tab title="Node">
            Install Nango's backend SDK with `npm i @nangohq/node`. Then run:

            ```typescript theme={null}
            import { Nango } from '@nangohq/node';

            const nango = new Nango({ secretKey: '<NANGO-SECRET-KEY>' });

            const res = await nango.get({
                endpoint: '/v1.0/me/drive/items/{fileId}/workbook/worksheets',
                providerConfigKey: '<INTEGRATION-ID>',
                connectionId: '<CONNECTION-ID>'
            });

            console.log(res.data);
            ```
          </Tab>
        </Tabs>

        Or fetch credentials dynamically via the [Node SDK](/reference/sdks/node#get-a-connection-with-credentials) or [API](/reference/api/connection/get).

        <Note>
          The `{fileId}` in the URL is the unique identifier for the Excel file in OneDrive/SharePoint. You can obtain this ID by first making a Nango [proxy](/reference/api/proxy/get) call to `/v1.0/me/drive/root/children` to list files and retrieve their IDs. Then, use the ID of the desired workbook to access its worksheets.
        </Note>
      </Step>
    </Steps>

    ✅ You're connected! Check the [Logs](https://app.nango.dev/dev/logs) tab in Nango to inspect requests.

    <Tip>
      Next step: [Embed the auth flow](/guides/primitives/auth) in your app to let your users connect their Microsoft Excel accounts.
    </Tip>
  </Tab>

  <Tab title="🧑‍💻 OAuth app setup">
    <Steps>
      <Step title="Create a Microsoft account and Azure account">
        If you don't already have them, sign up for a [Microsoft account](https://account.microsoft.com/account) and an [Azure account](https://azure.microsoft.com/free).
      </Step>

      <Step title="Register an application in Microsoft Entra ID">
        1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com) as at least an Application Developer.
        2. If you have access to multiple tenants, use the Settings icon in the top menu to switch to the tenant in which you want to register the application.
        3. From the search bar at the top of the Azure portal, search for **App registrations** and select it. Then choose **New registration**. Or from your left navigation tab, navigate to **Applications** > **App registrations** then choose **New registration**.
        4. Enter a meaningful name for your application, for example "Nango Integration".
        5. Under **Supported account types** you need to decide who can install your integration:
           * **Accounts in any organizational directory** - Any user account in a professional Microsoft organization (Business, School, etc.)
           * **Accounts in any organizational directory and personal Microsoft accounts** - The accounts from the first option, plus personal Microsoft accounts (pick this unless you want to restrict your integration to business accounts)
        6. Leave the **Redirect URI** section blank for now; we'll configure it in a later step.
        7. Click **Register** to complete the app registration.
      </Step>

      <Step title="Note your application (client) ID">
        After registration, you'll be taken to the application's Overview page. Record the **Application (client) ID**, which uniquely identifies your application and is used in your application's code as part of validating security tokens.
      </Step>

      <Step title="Add a redirect URI">
        1. In the left sidebar, select **Authentication**.
        2. Under **Platform configurations**, select **Add a platform**.
        3. Select **Web** as the platform type.
        4. Enter `https://api.nango.dev/oauth/callback` as the Redirect URI.
        5. Under **Advanced settings**, keep **Allow public client flows** set to the default **No** for web applications.
        6. Click **Configure** to save your changes.
      </Step>

      <Step title="Add API permissions">
        1. In the left sidebar, select **API permissions**.
        2. Click **Add a permission**.
        3. Select **Microsoft Graph** to integrate with **Microsoft Excel**.
        4. Select the required permissions from the **Delegated permissions section**.
        5. Select the specific permissions your app requires. Please refer to the table below for some of the [commonly used scopes](#common-scopes).
        6. Click **Add permissions**.
        7. If your application requires admin consent, click **Grant admin consent for \[tenant]** to pre-authorize the permissions.
      </Step>

      <Step title="Create a client secret">
        1. In the left sidebar, select **Certificates & secrets**.
        2. Under **Client secrets**, click **New client secret**.
        3. Enter a description for the secret and select an expiration period (6 months, 12 months, 24 months, or custom). Please select a date further in the future to avoid interruptions, note that the **Custom** date can only be set to a maximum of 1 year from the current date. If the secret expires, you will need to regenerate a new one and update your integration within Nango.
        4. Click **Add**.
        5. **Important**: Copy the secret value immediately and store it securely. You won't be able to see it again after you leave this page.
      </Step>

      <Step title="Configure token settings (optional)">
        1. In the left sidebar, select **Token configuration**. Here you can configure optional claims to be included in the access tokens issued for your application.
        2. Click **Add optional claim** and select the claims you want to include in your access tokens.
      </Step>

      <Step title="Configure app visibility (optional)">
        If you want users to see your app on their My Apps page:

        1. From the search bar at the top of the Azure portal, search for **Enterprise applications**, select it, and then choose your app.
        2. On the **Properties** page, set **Visible to users?** to **Yes**.
      </Step>

      <Step title="Next">
        Follow the [*Quickstart*](/getting-started/quickstart).
      </Step>
    </Steps>

    ## Common Scopes

    | Scope                 | Description                                          |
    | --------------------- | ---------------------------------------------------- |
    | `offline_access`      | Access to refresh tokens for offline access          |
    | `Files.Read`          | Read user files and files shared with user           |
    | `Files.ReadWrite`     | Read and write user files and files shared with user |
    | `Files.Read.All`      | Read all files that user can access                  |
    | `Files.ReadWrite.All` | Read and write all files that user can access        |
  </Tab>

  <Tab title="🔗 Useful links">
    ## Useful links

    | Topic     | Links                                                                                                                   |
    | --------- | ----------------------------------------------------------------------------------------------------------------------- |
    | General   | [Microsoft Entra Admin Center](https://entra.microsoft.com)                                                             |
    |           | [Azure Portal](https://portal.azure.com)                                                                                |
    |           | [Microsoft Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer)                                  |
    | Developer | [Microsoft identity platform documentation](https://learn.microsoft.com/en-us/entra/identity-platform/)                 |
    |           | [Microsoft Graph API Overview](https://learn.microsoft.com/en-us/graph/overview)                                        |
    |           | [How to register an Application](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app)     |
    |           | [OAuth 2.0 Authorization Code Flow](https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow) |
    |           | [Microsoft Graph Permissions Reference](https://learn.microsoft.com/en-us/graph/permissions-reference)                  |
    |           | [Microsoft Authentication Libraries (MSAL)](https://learn.microsoft.com/en-us/entra/identity-platform/msal-overview)    |
    |           | [Microsoft Graph API Reference](https://learn.microsoft.com/en-us/graph/api/overview)                                   |
    |           | [Microsoft Graph Throttling Guidance](https://learn.microsoft.com/en-us/graph/throttling)                               |
    |           | [Redirect URI Best Practices](https://learn.microsoft.com/en-us/entra/identity-platform/reply-url)                      |

    <Note>Contribute useful links by [editing this page](https://github.com/nangohq/nango/tree/master/docs/integrations/all/microsoft-excel.mdx)</Note>
  </Tab>

  <Tab title="🚨 API gotchas">
    * You can find permissions required for each API call in their corresponding API methods section, i.e, to list worksheet collections, you can have a look at [List worksheetCollection API permissions](https://learn.microsoft.com/en-us/graph/api/worksheet-list?view=graph-rest-1.0\&tabs=http#permissions).

    - Make sure you request the `offline_access` scope to get a refresh token and keep access with your integration.
    - Microsoft offers a tool that allows you to construct and perform Graph API queries and see their response for any apps on which you have an admin, developer, or tester role. For more information you can check [Microsoft Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer).
    - Please be aware that the Microsoft Graph API implements throttling to manage the volume of requests. For more information on handling throttling, refer to the [Microsoft Graph Throttling Guidance](https://learn.microsoft.com/en-us/graph/throttling).
    - Microsoft Graph API has different versions (v1.0 and beta). The v1.0 endpoint is for production use, while the beta endpoint contains features that are still in preview.
    - When requesting permissions that require admin consent, users without admin privileges will not be able to complete the OAuth flow unless an admin has pre-authorized the permissions.
    - For multitenant applications, you may need to handle tenant-specific endpoints and permissions.
    - You can set the [`.default` scope documentation](https://learn.microsoft.com/en-us/entra/identity-platform/scopes-oidc#default-when-the-user-gives-consent) to ensure the permissions remain the same as those granted at the organization level.
    - The `.default` scope can't be combined with the scopes registered in the Azure portal. So either just use the `.default` scope or remove it to list out explicit parameters that are required. If you attempt to combine them you'll receive the following error

    ```
    .default scope can't be combined with resource-specific scopes
    ```

    * If you need a user to reauthenticate or accept updated scopes, you can force a prompt using the `authorization_params`. Use `prompt=login` to force the user to enter their credentials (bypassing single-sign on) or `prompt=consent` to trigger the OAuth consent dialog after sign-in, which asks the user to grant permissions to the app. For more details, see [Microsoft's OAuth 2.0 authorization documentation](https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow#request-an-authorization-code).

    ```typescript theme={null}
    const { data } = await nango.createConnectSession({
      [...],
      integrations_config_defaults: {
        "<provider-name>": {
          authorization_params: {
            "prompt": "consent" // or "login" depending on your needs
          }
        }
      }
    });
    ```

    <Note>Contribute API gotchas by [editing this page](https://github.com/nangohq/nango/tree/master/docs/integrations/all/microsoft-excel.mdx)</Note>
  </Tab>
</Tabs>

<Info>
  Questions? Join us in the [Slack community](https://nango.dev/slack).
</Info>
