Invalid tenant ID provided while calling Graph API Endpoints

joaoaddyai 5 Reputation points
2024-07-25T16:17:03.4433333+00:00

Hello

I've been testing this endpoints locally, and everything works fine on localhost.

I deployed my backend and when I try to call the endpoint I now get this error.

Invalid tenant ID provided. You can locate your tenant ID by following the instructions here: https://learn.microsoft.com/partner-center/find-ids-and-domain-names

What do I need to do different?

I get the user access token with Auth JS on the frontend.

        url = "https://graph.microsoft.com/v1.0/me/mailFolders"
        headers = {
            "Authorization": f"Bearer {g.access_token}",
        }

        response = requests.get(url, headers=headers)
        if response.status_code != 200:
            return {
                "success": False,
                "error": f"Error getting labels: {response.content}"
            }, 400
        

        transformed_data = [transform_labels(folder) for folder in response.json()['value']]

        return transformed_data

Microsoft Security | Microsoft Graph
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Dillon Silzer 60,676 Reputation points Volunteer Moderator
    2024-08-05T17:11:01.2666667+00:00

    Hello,

    First of all, this is where you get your tenant ID:

    https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView?Microsoft_AAD_IAM_legacyAADRedirect=true

    User's image

    Secondly, what in Auth JS are you using to authenticate? Ensure you are looking at using Entra ID:

    https://authjs.dev/getting-started/providers/microsoft-entra-id


    If this is helpful please accept as answer or upvote.

    Best regards,

    Dillon Silzer | Cloudaen.com | Cloudaen Computing Solutions

    0 comments No comments

Your answer

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