I’m currently working on integrating OAuth 2.0 with my app using Uber Eats’ API in Retool, and I need help setting up a button to trigger the OAuth authorization flow.
What I'm Trying to Do:
I have successfully configured the OAuth 2.0 resource in Retool, including the authorization URL, token URL, client ID, and scopes. Now, I want to add a button to my UI that will redirect the user to Uber’s login page, where they can authorize the app. After authorization, Uber should send the user back to my specified redirect URI with an authorization code.
What I've Tried:
I added a button labeled "Authorize App" and attempted to use a Custom JS action to redirect the user to Uber's authorization URL. Here's the code I tried:
window.location.href = 'https://login.COMPANY.com/oauth/v2/authorize?client_id=MY_CLIENT_ID&response_type=code&redirect_uri=https://myapp.retool.com/oauth/callback&scope=XXX%YYY';
Issue:
I'm not sure if this is the right approach in Retool for initiating the OAuth flow. While this redirects the user to Uber’s login page, I’m not sure how to handle the response once the authorization code is returned, or if there’s a better way to trigger the OAuth flow using Retool’s built-in functionality.
Questions:
- Is there a better way to set up this button to trigger the OAuth flow using Retool’s OAuth resource instead of custom JavaScript?
- How can I handle the callback/authorization code in Retool once the user authorizes the app?
- Should I be using a different method to redirect and handle the OAuth flow entirely within Retool?
Any guidance or examples on setting up the OAuth flow properly with Retool would be greatly appreciated!