How to obtain an access token for microsoft Graph API in an outlook Add-In using Federated credentials

Suraj Sinha 5 Reputation points
2025-01-14T14:56:18.14+00:00

Hi Microsoft Team,

I am developing a React.js-based Outlook Add-In and for that I have been setting up a federated credential using GitHub Actions as the external Identity Provider (IdP) for an application in Microsoft Entra ID. What additional steps are needed to get an access token using the federated credential? Specifically, I want the token to be scope for calling Microsoft Graph API endpoints.

Below are the steps I have completed so far:

  1. To create a federated credential, a trust relationship must be established between an external identity provider (IdP) and an app in Microsoft Entra ID by configuring a federated identity credential.
  2. A software workload can exchange trusted tokens from the external identity provider for access tokens issued by the Microsoft identity platform.
  3. I chose GitHub Actions as the external identity provider to establish trust between Azure and the external IdP.
  4. Followed the steps outlined in the documentation to configure the federated identity credential for the application.
    https://zcusa.951200.xyz/en-us/entra/workload-id/workload-identity-federation-create-trust?pivots=identity-wif-apps-methods-azp#configure-a-federated-identity-credential-on-an-app

User's image

For set up in GitHub Action followed the steps as per steps in documentation:
Authenticate to Azure from GitHub Actions workflows | Microsoft Learn

  1. Created a repository and for that repository added secrets and variables shown in the snapshot below:
    a) Azure_ClientId
    b) Azure_TenantId User's image
  2. Created a New Workflow in GitHub Action: Action Tab > New Workflow > set up a workflow yourself.
    In “.yml” file added below code and committed the changes:

                           

on: [push]

permissions:

  ``id-token: write

  ``contents: read

 

name: Run Azure Login without subscription

 

jobs:

 

  ``build-and-deploy:

    ``runs-on: ubuntu-latest

    ``steps:

 

    ``- name: Azure Login

      ``uses: azure/login@v2

      ``with:

        ``client-id: ${{ secrets.AZURE_CLIENT_ID }}

        ``tenant-id: ${{ secrets.AZURE_TENANT_ID }}

        ``allow-no-subscriptions: true

        ``enable-AzPSSession: true

 

    ``- name: Azure CLI script

      ``uses: azure/cli@v2

      ``with:

        ``azcliversion: latest

        ``inlineScript: |

          ``az account show

 

    ``- name: Run Azure PowerShell

      ``uses: azure/powershell@v2

      ``with:

        ``azPSVersion: "latest"

        ``inlineScript: |

          ``Get-AzContext

  1. After running the Job build and deploy is being successful as shown in snapshot.
    User's imageQuestions: How can I obtain an access token from the configuration mentioned above that grants access to Microsoft Graph API?
Office
Office
A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.
1,831 questions
Outlook
Outlook
A family of Microsoft email and calendar products.
4,304 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,775 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,146 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
5,395 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.