4.8 KiB
OAuth Integration Callback URLs
This document provides information about the OAuth callback URLs used in Quizzical Beats for various authentication providers.
Overview
When configuring OAuth providers (Google, Authentik, Spotify, Dropbox), you need to set up redirect/callback URLs in each provider's developer console. These URLs tell the provider where to send users after they authenticate.
Callback URLs by Provider
Google OAuth
Callback URL: https://your-domain.com/users/login/google/callback
Local Development: http://localhost:5000/users/login/google/callback
When configuring Google OAuth in the Google Cloud Console:
- Go to "APIs & Services" > "Credentials"
- Create or edit an OAuth 2.0 Client ID
- Add the above URLs to the "Authorized redirect URIs" section
Authentik OAuth
Callback URL: https://your-domain.com/users/login/authentik/callback
Local Development: http://localhost:5000/users/login/authentik/callback
When configuring Authentik:
- Create an OAuth2/OIDC Provider
- Add the above URLs to the "Redirect URIs" field
- Ensure the scopes include "openid", "profile", and "email"
Spotify API
Callback URL: https://your-domain.com/users/spotify-callback
Local Development: http://localhost:5000/users/spotify-callback
When configuring Spotify in the Spotify Developer Dashboard:
- Go to your app's settings
- Add the above URLs to the "Redirect URIs" section
- Save the changes
Dropbox API
Callback URL: https://your-domain.com/users/dropbox-callback
Local Development: http://localhost:5000/users/dropbox-callback
When configuring Dropbox in the Dropbox Developer Console:
- Go to your app's settings in the Dropbox App Console
- Under "OAuth 2", add the above URLs to the "Redirect URIs" section
- Make sure you've selected the correct permission scopes:
files.content.readfiles.content.writesharing.writeoffline_access(for refresh tokens)
- Set the app status to "Production" if it's still in development mode
- In the "Permissions" tab, ensure all required scopes are selected
Environment Variables
Make sure to update the following environment variables in your .env file to match your configured callback URLs:
# For Google OAuth
GOOGLE_REDIRECT_URI=http://localhost:5000/users/login/google/callback
# For Authentik OAuth
AUTHENTIK_REDIRECT_URI=http://localhost:5000/users/login/authentik/callback
# For Spotify API
SPOTIFY_REDIRECT_URI=http://localhost:5000/users/spotify-callback
# For Dropbox API
# DROPBOX_REDIRECT_URI=http://localhost:5000/users/dropbox-callback
# Note: The Dropbox URL is automatically generated using Flask's url_for function
In production, update these URLs to use your actual domain.
Additional Notes
- Make sure your application is properly configured to handle these callback routes.
- For security, always use HTTPS URLs in production environments.
- When testing locally with HTTP, some providers may require you to explicitly allow HTTP redirects for development.
- If you're using Docker or other containerization, ensure your application is accessible at the configured URLs.
- Dropbox requires the app to be in "Production" mode for non-developers to use it.
Troubleshooting
If you encounter OAuth errors such as "invalid_redirect_uri" or "redirect_uri_mismatch":
- Verify that the callback URL is exactly the same in both your OAuth provider configuration and your application code.
- Check that the protocol (http vs https) matches what's configured.
- Ensure there are no trailing slashes unless specifically required.
- For development behind NAT/firewalls, you may need to use a service like ngrok to create a public URL.
- Check that the response data format matches what your code expects. For Google OAuth, ensure your code is accessing fields correctly (Google uses 'sub' for user IDs rather than 'id').
- Enable debug logging to inspect the full OAuth response payload to identify missing or incorrectly named fields.
- Verify that your OAuth scopes in the provider configuration match the scopes requested in your application code.
- Test with a minimal set of scopes first, then add more as needed once the basic flow works.
Dropbox-Specific Troubleshooting
If you see "This app is not valid" error from Dropbox:
- Make sure your app is configured in the Dropbox App Console
- Verify that your app key and app secret in your config match what's in the Dropbox console
- Ensure your redirect URI is correctly registered in the Dropbox console
- Check if your app needs to be in "Production" mode (it may be in development mode)
- Verify that you've selected all required permission scopes in the Dropbox console