Access Token Generation¶
This script is a simple Flask application that demonstrates the OAuth2.0 authorization flow with Miro’s API.
The application performs the following tasks: 1. Redirects users to Miro’s authorization page to obtain an authorization code. 2. Handles the callback from Miro after the user authorizes the application, exchanges the authorization code for an access token, and displays the access and refresh tokens.
To use this script, ensure that you have the required environment variables (MIRO_CLIENT_ID and MIRO_CLIENT_SECRET) set in a .env file.
Routes: - /: Redirects the user to the Miro authorization URL. - /callback: Handles the OAuth2.0 callback and exchanges the authorization code for an access token.
- access_token_generation.callback()¶
Handles the callback request from the Miro authorization server.
This function is a route handler for the ‘/callback’ URL. It retrieves the authorization code from the callback request, exchanges it for an access token, and extracts the access token from the response.
- Returns:
A string containing the access token and refresh token.
- access_token_generation.index()¶
Redirects the user to Miro’s authorization URL.
This function is a route handler for the root URL (“/”). It generates the authorization URL based on the authorization_base_url, client_id, and redirect_uri variables. The generated URL is then used to redirect the user to Miro’s authorization page.
- Returns:
A redirect response to the generated authorization URL.