Hello.
I’ve created a custom GPT that is meant to act as my personal assistant. It is meant to connect to my Microsoft data via the Microsoft Graph API. I’ve managed to successfully set up the function to at least allow me to sign into my Microsoft account and retrieve my user profile details. Unfortunately, that is where the fun stops for me.
This integration is meant to expand to include a wide variety of the Microsoft Graph API capabilities. But whenever I try to add and test any action that isn’t retrieving my account’s information, I get an error that says “The request does not contain a valid authentication token. Detailed error information: {0”.
I’ve asked ChatGPT for guidance but it seems to give me mixed information. For example, it suggests that I use the API Key Authentication type but it is required that I use the Oauth type for Microsoft Graph. So, I’m stuck.
Anything help would be greatly appreciated.
If you’d like to replicate my setup to troubleshoot for yourself, here is how I have everything configured.
1. As per Microsoft's instructions, within my Azure portal, under Microsoft Entra ID, I created a new app and acquired my Client ID and Client Secret.
a. FYI: The app's Supported Account types are "All Microsoft Account Users".
b. FYI: By default, the only scope in the app's API Permissions section is "Microsoft Graph: User.Read". You may have to add the "Notes.ReadWrite.All" permission as well.
2. Within the GPT editor, I set up Oauth authentication with the following configurations;
a. Client ID: <Azure app's Client ID>
b. Client Secret: Azure app's Client Secret Value (Not Secret ID string as this returns a "Missing Access Token" error)
c. Authorization URL: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
d. Token URL: https://login.microsoftonline.com/common/oauth2/v2.0/token
e. Scope: User.Read Notes.ReadWrite.All
f. Token Exchange Method: Default (Post request)
3. I added the GPT's callback URL to the Redirect URI within my Azure app's Authentication settings.
a. FYI: Each time you change the GPT's Client ID and Client Secret values, you must save and refresh the tab to get the updated callback URL.
4. I had GPT whip up some basic JSON and copy pasted it into the GPT's schema.
a. FYI: Sometimes, adding a new JSON will also require you to save and refresh the tab to get the updated callback URL
Here is the JSON I have;
{
"openapi": "3.1.0",
"info": {
"title": "A.D.A GPT Microsoft Graph Integration",
"version": "1.0.0",
"description": "This specification outlines the integration of A.D.A GPT with the Microsoft Graph API to access and manage the user's profile and OneNote data."
},
"servers": [
{
"url": "https://graph.microsoft.com/v1.0",
"description": "Microsoft Graph API server"
}
],
"paths": {
"/me": {
"get": {
"operationId": "getUserProfile",
"summary": "Get User Profile",
"description": "Retrieve the user's profile information from Microsoft Graph.",
"responses": {
"200": {
"description": "Successful response with user profile data.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserProfile"
}
}
}
},
"401": {
"description": "Unauthorized request due to invalid or missing authentication token."
},
"403": {
"description": "Forbidden request due to insufficient permissions."
}
}
}
},
"/me/onenote/notebooks": {
"get": {
"operationId": "getOneNoteNotebooks",
"summary": "Get OneNote Notebooks",
"description": "Retrieve the user's OneNote notebooks.",
"responses": {
"200": {
"description": "Successful response with OneNote notebooks data.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OneNoteNotebooks"
}
}
}
}
}
}
},
"/me/onenote/sections": {
"get": {
"operationId": "getOneNoteSections",
"summary": "Get OneNote Sections",
"description": "Retrieve the user's OneNote sections.",
"responses": {
"200": {
"description": "Successful response with OneNote sections data.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OneNoteSections"
}
}
}
}
}
}
},
"/me/onenote/pages": {
"get": {
"operationId": "getOneNotePages",
"summary": "Get OneNote Pages",
"description": "Retrieve the user's OneNote pages.",
"responses": {
"200": {
"description": "Successful response with OneNote pages data.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OneNotePages"
}
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"OAuth2": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
"tokenUrl": "https://login.microsoftonline.com/common/oauth2/v2.0/token",
"scopes": {
"User.Read": "Read user profile",
"Notes.ReadWrite.All": "Read and write all OneNote content"
}
}
}
}
},
"schemas": {
"UserProfile": {
"type": "object",
"properties": {
"displayName": {
"type": "string"
},
"mail": {
"type": "string"
}
}
},
"OneNoteNotebooks": {
"type": "object",
"properties": {
"value": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Notebook"
}
}
}
},
"Notebook": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"displayName": {
"type": "string"
},
}
},
"OneNoteSections": {
"type": "object",
"properties": {
}
},
"OneNotePages": {
"type": "object",
"properties": {
}
}
}
},
"security": [
{
"OAuth2": ["User.Read", "Notes.ReadWrite.All"]
}
]
}
Any guidance would be greatly appreciated.