# \[Help needed\]Created needed api but its not working inside bubble need help 0w0

**URL:** <https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668>\
**Category:** APIs\
**Created:** [January 10, 2022, 1:11am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668 "2022-01-10T01:11:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 1:11am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/1 "2022-01-10T01:11:14Z")

</div>

Hello i created this plugin to exchange a users `?code=` from url `using get data from url` but the issue at hand is i can not seem to get this to exchange for the access\_token or even save a `access_token` i know the calls are right via the api ive tested it and everything comes up right but sadly inside bubble it will not keeps saying wrong code even tho it hasnt even been the nessesarcy timeout on the code to exchange it for a `access_token` if someone on here can help me it mean the world its not like im sitting here i the forums not trying heres the proof

> Need help to get this plugin working to exchange a code for access\_token and save said token via web storage local storage db. 🙏  
> [Plugins | Bubble](https://bubble.io/plugin/discord---accesstoken-1641776673841x746883553744912400)

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [January 10, 2022, 3:25am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/2 "2022-01-10T03:25:16Z")

</div>

You have set the type to client credentials, but this oAuth2 process doesn’t accept code. You probably doesn’t have the correct type (normally it’s authorization\_code and sometimes it’s just code).

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 3:59am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/3 "2022-01-10T03:59:35Z")

</div>

im confused then as why my plugin works but on bubble it does not @Jici  
…

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:00am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/4 "2022-01-10T04:00:36Z")

</div>

> [@Jici](#):
>
> You have set the type to client credentials, but this oAuth2 process doesn’t accept code. You probably doesn’t have the correct type (normally it’s authorization\_code and sometimes it’s just code).

the code part you are speaking of is returned via the oauth2 redirect… i got that the code but the exchange wont work inside of bubble only plugin

thank you again for attempting to help me it means alot its been a few days ive been on this issue

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [January 10, 2022, 4:01am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/5 "2022-01-10T04:01:45Z")

</div>

Yes, but in the plugin, you have selected client\_credentials for the type. This is nt compatible with the authorization\_code from the redirect.

You should share screenshot of your setting in Bubble instead of a link to plugin if the issue is in API connector

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:02am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/6 "2022-01-10T04:02:23Z")

</div>

um no i havnt … im confused

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/8/b/8bb52c2f95b49636aa944c226f00ed300ca1e7d2.png)

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:03am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/7 "2022-01-10T04:03:15Z")

</div>

i can attempt to share as much as i can but i dont want to accidently leak my own access\_token lol

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [January 10, 2022, 4:08am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/8 "2022-01-10T04:08:45Z")

</div>

Actually, you have set an HTTP Basic auth. This is not the case.  
You have two options: oAuth2 User Grant flow or none.  
If none, you will do each step manually. Use a link to the authorize url, use Get data from page url with the Code and process the code into api Token endpoint.

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [January 10, 2022, 4:10am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/9 "2022-01-10T04:10:27Z")

</div>

You cannot ask bubble to handle the auth and try to do it manually in your calls after.

 ![screenshot-bubble.io-2022.01.09-23_09_42](https://us1.discourse-cdn.com/bubble/original/3X/5/7/57d1e850734b1c188c0b208b0958a34969cee0f0.png)

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:25am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/10 "2022-01-10T04:25:48Z")

</div>

> [@Jici](#):
>
> You should share screenshot of your setting in Bubble instead of a link to plugin if the issue is in API connector

> Alright so @Jici on login a user is brought too  
> `https://discord.com/oauth2/authorize?client_id=891335306681384962&redirect_uri=https%3A%2F%2Fdislist.me%2Fapi%2F1.1%2Foauth_redirect&response_type=code&state=%257B%2522oauth_provider%2522%253A%25221640977923756x701742010930036700%2522%252C%2522resume_key%2522%253A%25221641787544689x650044442962245600%2522%252C%2522used_redirect_url%2522%253A%2522https%253A%252F%252Fdislist.me%252Fversion-test%252Flogin%2522%252C%2522redirect_unique_id%2522%253A%25221641787544988x639126127394641500%2522%257D&scope=email%20identify%20guilds%20guilds.join%20guilds.members.read%20messages.read%20email%20identify%20guilds%20guilds.join%20guilds.members.read%20messages.read%20connections`
> 
> ![image](https://us1.discourse-cdn.com/bubble/original/3X/7/0/7076225cf380e7a85ec297c750972632f8151635.jpeg)

then from here the user is brought back threw [https://dislist.me/api/1.1/oauth\_redirect](https://dislist.me/api/1.1/oauth_redirect) which brings back to the `https://dislist.me/version-test/login` page but in the image as you see + the copied url im given a code i put that code in from the url  
into the call and get my token just fine  
`https://discord.com/api/oauth2/token?response_type=code&client_id=891335306681384962&scope=identify%20guilds.join&state=15773059ghq9183habn&redirect_uri=https%3A%2F%2Fdislist.me/api/1.1/oauth_redirect&grant_type=authorization_code&code=<code>`

the user is logged in but i cant exchange the access code for token or figure out how to get the access\_token ive tried via saving to user saving to web storage and more but i cant seem to get this to work if need be if you like i can spin up a new testing discord account for you if you do not have one (call it a dummy account more or less lol)

heck i dont mind even inviting you over into the plugin if im able to

But below we can see the code  
`https://dislist.me/version-test/login?code=J0CUxWvEorq6Sxk4sBe0mvjqbzZKqQ&state=%257B%2522oauth_provider%2522%253A%25221640977923756x701742010930036700%2522%252C%2522resume_key%2522%253A%25221641788261326x505606070020973250%2522%252C%2522used_redirect_url%2522%253A%2522https%253A%252F%252Fdislist.me%252Fversion-test%252Flogin%2522%257D`

i can save said code to said user via the db as we see the  
`?code=J0CUxWvEorq6Sxk4sBe0mvjqbzZKqQ`

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/7/9/79bf050bea7a692ad9fa5d222b073d5bef5e387c.png)  
but yet when i use a action or even set my plugin for the code exchange to attempt to get access\_token it wont go threw always `error wrong code` but its the same code i would of used to even autheticate the plugin its self of course not same exact code as it changes and expires in a short time but not short enought i cant run a api or use it to thus later add user to the server after but i can not do this with out the above so i hope these things help explaining more

The api call for this aspect for the code to get token is as such

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/7/f/7ff639472dcba9e91e6bdb2067df75d81e407807.png)

http basic auth which is suppose to be used from what I’m being told from reading the documentation over at discord - which works btw look below i was provided my token and refresh token as well

 ![Screenshot 2022-01-09 231242](https://us1.discourse-cdn.com/bubble/original/3X/e/d/ed17846f9dec9178694de23870bbb27302384c0d.png)  
so im highly confused as what todo here m8

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:26am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/11 "2022-01-10T04:26:02Z")

</div>

attempting this m8 atm brb

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [January 10, 2022, 4:33am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/12 "2022-01-10T04:33:15Z")

</div>

You don’t use basic auth in Bubble API Connector. You set to None/self-handled because this iswhat you are doing.  
NowYou need to store the access token in DB and use it in other API endpoint.  
You have the access token according from your screenshot. Copy it and initialize other API call using an header on each other call “Authorization: Bearer accesstokenhere”

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:33am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/13 "2022-01-10T04:33:17Z")

</div>

isnt that my token tho no matter who makes the call as im the bot owner thats what im understanding from documentation here as i already have this call and it returns the bots access\_token or mine not the users

## Client Credentials Grant

The client credential flow is a quick and easy way for bot developers to get their own bearer tokens for testing purposes. By making a `POST` request to the [token URL](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-urls) with a grant type of `client_credentials`, using Basic authentication with your client id as the username and your client secret as the password, you will be returned an access token for the bot owner. Therefore, always be super-extra-very-we-are-not-kidding-like-really-be-secure-make-sure-your-info-is-not-in-your-source-code careful with your `client_id` and `client_secret`. We don’t take kindly to imposters around these parts.

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [January 10, 2022, 4:34am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/14 "2022-01-10T04:34:28Z")

</div>

Client credentials is a different thing. The authorize url use the authorization\_code grant, not the client credentials.

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:34am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/15 "2022-01-10T04:34:50Z")

</div>

🙏thank you for taking this precious time of yours to help me out btw

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:35am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/16 "2022-01-10T04:35:36Z")

</div>

> [@Jici](#):
>
> Client credentials is a different thing. The authorize url use the authorization\_code grant, not the client credentials.

could i please invite you to the plugin this is very confusing to me and actually ive been stuck on it for 8 days now 4 days of no sleep

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:36am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/17 "2022-01-10T04:36:05Z")

</div>

im not asking you to write the whole plugin lol i can do whats needed but i need more info im a visual learner

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:37am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/18 "2022-01-10T04:37:56Z")

</div>

again heres my confusion your telling me not to run the plugin using what im using and use none or self handled it dosnt work  
ive tried the documentation even says as so

The client credential flow is a quick and easy way for bot developers to get their own bearer tokens for testing purposes. By making a `POST` request to the [token URL](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-urls) with a grant type of `client_credentials` , using Basic authentication with your

Make a post request using basic auth

`for bot developers to get their own bearer tokens for testing purposes` this is my token not the said users i have the calls for users already m8

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:39am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/19 "2022-01-10T04:39:05Z")

</div>

just how to implicate it with bubble

---

<div class="post-metadata">

**Author:** ![moran.storm.5050](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/moran.storm.5050/32/113110_2.png) [@moran.storm.5050](https://forum.bubble.io/u/moran.storm.5050)\
**Post date:** [January 10, 2022, 4:41am UTC](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668/20 "2022-01-10T04:41:28Z")

</div>

also this is the first call in my api ive shared in the forum

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/6/b/6be5434204f32c70c02adc2ddda50dc992d2eb16.png)

so thank you kindly for your help 🙏 but you seem to be as lost as i am

[Next page](https://forum.bubble.io/t/help-needed-created-needed-api-but-its-not-working-inside-bubble-need-help-0w0/185668.md?page=2)
