You can connect to Microsoft Graph using Retool's REST API integration and make it available as a resource. Once complete, you can write queries to interact with the Microsoft Graph API.
Requirements
All users for Retool organizations on Free or Team plans have global Edit permissions and can add, edit, and remove resources. If your organization manages user permissions for resources, you must be a member of a group with Edit all permissions.
To create your Microsoft Graph resource, you need:
Microsoft Graph uses OAuth 2.0 authentication. You must create an OAuth 2.0 client application with Microsoft Graph that Retool uses to perform authentication. Refer to the Microsoft Graph documentation to learn how to create a client application and obtain the required credentials.
If Microsoft Graph is behind a firewall, you must also allow access from Retool's IP addresses. Add these IP addresses to your firewall's allowlist before you create the resource.
1. Create a new resource
Sign in to your Retool organization and navigate to the Resources tab. Click Create new, then select Resource.
Retool can connect to almost any API or database, and has built-in integrations for popular data sources. Select the REST API integration.
2. Configure the resource
Provide the necessary details to configure the resource so Retool can connect to Microsoft Graph. Not all settings are required but refer to the Microsoft Graph documentation to learn what is needed.
General
These settings configure the name and location of the resource within Retool.
Name
The name to use for the resource (e.g., Microsoft Graph).
Folder
The folder in which to save the resource.
Description
A brief description of the resource (e.g., Customer data).
Credentials
These settings configure how Retool connects to Microsoft Graph.
Base URL
The base URL for the Microsoft Graph API. This must be an absolute URL. Use https://graph.microsoft.com/{version}/{resource}
.
URL parameters
Key-value pairs to include as URL parameters with Microsoft Graph API requests. No additional URL parameters are required.
Headers
Key-value pairs to include as headers with Microsoft Graph API requests. Include the following key-value pairs:
Key | Value |
---|---|
Authorization | Bearer OAUTH2_TOKEN |
Body
Key-value pairs to include in the body of Microsoft Graph API requests. No additional body values are required.
Cookies
Cookies to include with Microsoft Graph API requests. No cookies are required.
Authentication
The method of authentication to use with Microsoft Graph. Select OAuth 2.0
.
Retool supports the server-side OAuth 2.0 authentication flow as well as the Client Credentials flow. In both cases, you must use the OAUTH2_TOKEN
placeholder to inform Retool where to place the OAuth access token in the API request. A common location for this is a header such as Authorization: Bearer OAUTH2_TOKEN
.
Setting | Description | |
---|---|---|
Use Client Credentials Flow | Whether to obtain an access token as an app, rather than a user. Authentication will be shared across users. | |
Authorization URL | The OAuth 2.0 callback URL. | |
Access Token URL | The OAuth 2.0 authorization URL. | |
Client ID | The OAuth 2.0 client ID. | |
Client Secret | The OAuth 2.0 client secret. | |
Scopes | The scope of the access to request. Multiple scopes need to be separated by a space. Learn more about the available scopes in the Microsoft Graph documentation. | |
Audience | The OAuth 2.0 audience. | |
Enable an auth verification endpoint | Whether Retool uses a verification endpoint to determine if a user should be prompted to authenticate when an app is first loaded. | |
Share credentials between users | Whether to share authentication credentials between users. All requests to the API will be executed as the authenticated user. |
Forward all cookies
Whether to forward all cookies. This is useful if you have dynamic cookie names.
3. Save the resource
Click Create resource to complete the setup. You can then click either Create an app to immediately start building a Retool app or Back to resources to return to the list of resources.
Wrap up
Your Microsoft Graph resource is now ready to use. You write queries to make API requests by specifying the request method and endpoint, additional parameters to include, and the request body.
To verify you can successfully interact with Microsoft Graph, write a test query to retrieve some data. The following example retrieves your user details.
- Request
- Response
GET https://graph.microsoft.com/v1.0/users/me
{
"data": {
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"displayName": "Jenny Appleseed",
"surname": "Appleseed",
"givenName": "Jenny",
"id": "abc123",
"userPrincipalName": "jenny.appleseed@example.com",
"businessPhones": [],
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null
}
}