# API connector OAuth2 different dev and prod env

**URL:** <https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162>\
**Category:** Plugins\
**Created:** [July 12, 2022, 3:41pm UTC](https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162 "2022-07-12T15:41:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vicente1](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vicente1](https://forum.bubble.io/u/vicente1)\
**Post date:** [July 12, 2022, 3:41pm UTC](https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162/1 "2022-07-12T15:41:55Z")

</div>

Hi

I’m using an API that requires OAuth2 authentication. It works fine. However, some data for the token generation should change from development version to production version. More specifically, the URL and one header in the request to get the token must be different in development and production environments, but I haven’t found a way to change them dynamically or anything like that.

Is there some kind of workaround? It is way to impractical to change them manually at each deployment.  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![diegohsitec](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@diegohsitec](https://forum.bubble.io/u/diegohsitec)\
**Post date:** [July 12, 2022, 5:57pm UTC](https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162/2 "2022-07-12T17:57:55Z")

</div>

@vicente1 forgive me the question, but you managed to integrate with which identity provider?

---

<div class="post-metadata">

**Author:** ![paul29](https://avatars.discourse-cdn.com/v4/letter/p/5f8ce5/32.png) [@paul29](https://forum.bubble.io/u/paul29)\
**Post date:** [July 12, 2022, 5:58pm UTC](https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162/3 "2022-07-12T17:58:42Z")

</div>

Use the “isn’t live version” which evaluates to a yes/no and then use the “:formatted as text” and then in formatting for yes, put the info for your dev version and then in formatting for no, put the info for your live version

---

<div class="post-metadata">

**Author:** ![vicente1](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vicente1](https://forum.bubble.io/u/vicente1)\
**Post date:** [July 13, 2022, 7:24am UTC](https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162/4 "2022-07-13T07:24:30Z")

</div>

> [@diegohsitec](#):
>
> identity provider?

edit: I had replied the wrong answer 😅  
edit 2: small error correction

So I actually didn’t know what you meant with “identity provider” in this context, but from a simple search I think you mean the endpoint / url where I get the authentication, is it right?

If so, it’s the authentication endpoint for Mangopay service. For the production environments I would use [https://api.mangopay.com/v2.01/oauth/token/](https://api.mangopay.com/v2.01/oauth/token/) and for the development, I would use a sandbox environment [https://api.sandbox.mangopay.com/v2.01/oauth/token/](https://api.sandbox.mangopay.com/v2.01/oauth/token/). You can check the authentication scheme here [Mangopay documentation](https://docs.mangopay.com/guide/authentification) .

---

<div class="post-metadata">

**Author:** ![vicente1](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vicente1](https://forum.bubble.io/u/vicente1)\
**Post date:** [July 13, 2022, 7:31am UTC](https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162/5 "2022-07-13T07:31:43Z")

</div>

That works for the normal endpoints/url, but the native Bubble OAuth2 does not support variables in the Token url and headers. I can change them in the finals urls where I’ll get information, but not in the token url that I access to get the authorization temporary token.

---

<div class="post-metadata">

**Author:** ![vicente1](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vicente1](https://forum.bubble.io/u/vicente1)\
**Post date:** [July 13, 2022, 7:40am UTC](https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162/6 "2022-07-13T07:40:58Z")

</div>

I actually have two workarounds, but they are a little complicated and prone problems in future modifications.  
Workaround 1: Make a manual system to handle the OAuth2 token refresh. Just a variable with the valid token and a scheduled backend workflow that refresh it or just check and refresh if required every time I need to use. With so, I can make have one token for dev and one for prod and use each one accordingly. It is rather annoying to insert the token every time and not use the native OAuth2 system, but maybe not horrible.  
workaround 2: Make two different API groups, one for dev and one for prod and in the workflow put them both with “Only when …” conditions accordingly. It is more prone to forget it in the future and it probably will be annoying to treat both responses the same way.

---

<div class="post-metadata">

**Author:** ![Lucien](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/lucien/32/58216_2.png) [@Lucien](https://forum.bubble.io/u/Lucien)\
**Post date:** [August 14, 2022, 9:52pm UTC](https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162/7 "2022-08-14T21:52:05Z")

</div>

Faced the same limitation and couldn’t find a better workaround (I went with option 2) 😕

Probably too much of a low hanging fruit for the Bubble team to have missed it, so I’m wondering what’s the actual reason for not allowing variables in there 🤔

---

<div class="post-metadata">

**Author:** ![vicente1](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vicente1](https://forum.bubble.io/u/vicente1)\
**Post date:** [August 16, 2022, 7:57am UTC](https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162/8 "2022-08-16T07:57:56Z")

</div>

I personally started handling it manually (workaround 1). I saved the token as a variable (with its value, expire date and a condition if it is prod or dev) in the database and created a custom WF that checks the token, so I call it before every API action.  
The WF is the following : delete all old tokens; stop if there is a valid token; get a new token; create a new token object in the database.  
Then, when making API requests, I used variable fields (the [] and \<\> in the request) with the function “Isn’t live version”.  
It takes more work to implement, but if you have a large number of API requests, it is basically just copy and paste, so it’s not impossible.

---

<div class="post-metadata">

**Author:** ![demondragong](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/demondragong/32/160551_2.png) [@demondragong](https://forum.bubble.io/u/demondragong)\
**Post date:** [December 12, 2023, 5:53am UTC](https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162/9 "2023-12-12T05:53:17Z")

</div>

Hi guys.

I’m facing the same issue of having to handle dev and prod for a set of similar calls (different Token endpoints, different parameters), and haven’t found anyone else talking about this on the forum 🤯

It’s interesting that you each went with a different workaround @vicente1 @Lucien

I wanted to ask you if you had found a better solution since then or if, in hindsight, you were happy with the option you picked.

---

<div class="post-metadata">

**Author:** ![stephane](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/stephane/32/59586_2.png) [@stephane](https://forum.bubble.io/u/stephane)\
**Post date:** [March 15, 2024, 3:17pm UTC](https://forum.bubble.io/t/api-connector-oauth2-different-dev-and-prod-env/215162/10 "2024-03-15T15:17:08Z")

</div>

Same here @bubble it is possible to set `params []` for `login redirect` but not `access token endpoint` and `user profile endpoint` ?

This just keep us making unmaintable (no) code…

 ![CleanShot 2024-03-15 at 16.11.38 2@2x](https://us1.discourse-cdn.com/bubble/original/3X/d/0/d05d79cdd1750a422b0ab2f10f12b9d6bebee18e.png)
