Gummie was hallucinating in telling me how to use Call API to get a bearer token (which I can then use to call one of our APIs).
How can I automate the process of getting a bearer token, e.g. using OAuth2?
What I need to do is :
On an initial run the flow will realise that there is no bearer token and will ask the user to login with email and password to get the bearer token
On subsequent runs, if the bearer token exists and has not expired the flow will use that bearer token.
Ideally before the bearer token expires the flow will either refresh it, or if it can’t do that, it will realise that the bearer token has expired and will ask the user to login again.
There are lots of use cases where users need to login to Azure ADB2C (or similar) before they can call an API, so I’m hoping that this is something that gumloop will support (or at least show me how to do). Thanks!
Hey @Patrick_Lee - You’d probably have to create a custom node for this. You’d have to OAuth once yourself separately to get the refresh token, and then just have code to get a new access token every time.
Thanks @Wasay-Gumloop - I can’t see how a custom node helps with the situation where it seems step 1) I need to call an Authorisation URL to get an authorization code, and then step 2) I need to call the Access token URL to get the bearer token, but where as part of step 1 I need to login with user and password. I tried putting in the clientId, Azure domain, signin flow/policy, and scope and asked AI to generate the code and it wrote code to set up some local server (local host) which didn’t work.
Yeah this is definitely tricky to setup and you’d have to go through a fair bit of trial and error with AI. You’d have to OAuth once yourself separately to get the refresh token, and then just have code to get a new access token every time.
If it doesn’t work after a few attempts I’d recommend looking for a workaround rather than automating fetching the bearer token end to end.