Dynamic url with REST Api via oAuth2 client credentials

Hey!

I want to connect different api's with each other, the api's will have an identical id/secret, but a different url. I know this is possible by simply creating a separate resource for every environment / api. So for example:

  1. env1.com/api <<resource1
  2. env2.com is for sale | HugeDomains <<resource2
  3. env3.com/api <<resource3

But as I want to connect a lot of api's, the resource list will be very long and I need to constantly authorize every environment. So my question is, is it possible to make the url dynamic?

So let's say the clientid + secret is the same for every environment.

  • Clientid = xxx
  • Clientsecret = xxx
  • Authorize url = https://{{text1.value}}/api/authorize
  • Token url = https://{{text1.value}}/api/token

So I can basically connect different environments / api's, using the same resource. The url will be given by the user.

Kind regards,

Jesper

Hey @jesperlist!

What kind of auth setup are you using with this resource?

It's certainly possible to define URLs/headers dynamically when setting a REST API as your resource - you can leave the base URL empty in your resource setup and pass https://{{text1.value}}/api/authorize directly to the URL field:

You can do something similar with the headers and keep the client id and secret in the resource setup. If you're looking to fetch a token dynamically based on user input with the token url you may have to run a separate query to do that first and then pass its result to subsequent requests.

Does that sound like it could fit what you're looking for?

Hey @Kabirdas ,

Thanks for your reply!
So I should call /authorize and /token in the query instead of in the resource? So I should leave these values empty in the resource?

Kind regards,

Jesper

Yep! You'd typically set the base URL in the resource and add anything on top of that. So since the user is setting the base URL in the app itself, I'd put at most https:// in the resource configuration. Let us know if it all works!

It's not sending the the id/secret I configured in the resource in the body of the query. But I'm just going to configure the id/secret in a REST query, so not going to use a resource at all.

Thanks

Got it, if you'd like we can take a look at your resource set up to see why it's not sending. Otherwise, good to know you have a way of making it work :slightly_smiling_face: