Application/x-www-form-urlencoded

Hi, I am using an API that uses OAuth 2.0 and x-www-form-urlencoded. The API gives me a client_id (public), a client_secret (private), and grant_type called client_credentials to access the API. I first have to perform a post request that generates a token. Once I have the token I use it in a header

Key: Authorization Value: Bearer {{token}}

I have tried variations of all the OAuth 2.0 options provided by bubble.
Here is my current attempt:


I have also tried having the key be ‘None or self handled’ and then doing an API call to get the token:


When I attempt to initialize this call I get the response:

I think the right way to do it is a post call to get the token → use the call in a workflow and get the token → use ‘result of step x’ in another workflow to do other calls.

This works easily in postman so I know its possible. I have done normal auth key JSON calls before but the ‘application/x-www-form-urlencoded’ is really throwing me off. Any ideas would be greatly appreciated.

I have looked at a few of the application/x-www-form-urlencoded threads but their solutions have not worked for me.

http://forum.bubble.io/t/application-x-www-form-urlencoded-error/77001

Please respond if you have a solution or if you would like more info.

Everything is much appreciated!

Try Content-Type not Content_Type

Make sure you check your parameters as querystring

Thank you for the suggestion @doug.burden and @johnny , I tried both of them but no luck so far.

I have tried to copy the postman(which works) into bubble api connector(doesn’t work)
Im going to put screenshots of the postman vs the bubble api connector please let me know if you have any ideas!

Bubble:
API:


Response:

Postman:
Headers and response:

Body:

Params(none):

I think that I may have to turn the body into parameters? but I have tried various ways.

The Bubble part is set up to what I think is copying the postman exactly but no luck.

Nawl big dawg. Remove the body and just make them parameters, checked querystring

Thanks for replying @doug.burden ! I just did that but it still doesn’t work, am I doing something wrong?



Oh Nawl big dawg, construct your auth url in a Open external page action

Client credentials should be used with custom oauth2 token. So your first screenshot is almost correct. But in most case, you will have a basic authorization header and you shouldnt have the header grant typre, that is in the url parameters.

Do.you have a link to api doc?

Yes, thanks @Jici here is api doc. I tried oauth 2.0 token but didnt work. I probably did something wrong

for the authentication url you can build it in the open external website

then use the api connector to get your token

and so the grant type parameter is going to be

client_credentials&client_id=client_id&client_secret=client_secret

make sure grant_type is a querystring

@doug.burden what do you mean by open external website?

forget about that right now, you’re already at the part of getting a token.

Just make the grant_type parameter and supply the value I gave you and try it real quick

So,

Parameters
key: grant_type value: client credentials
key: client_id value:xxxxxxx
key: client_secret value:yyyyyyyy

no

Parameter
grant_type

in the value for grant_type use “client_credentials&client_id=someones_client_id&client_secret=someones_client_secret”

Ok I did that while replacing the client id, etc. but got new response that says grant_type is wrong. Thanks for all your help really appreciated!!

you in a pickle… let me think

For my OCD can you make your content-type Content-Type

Same Response as last time :frowning:

Yea I didn’t expect a different result, just had my eye ticking

3 params, all querystring

grant_type
client_id
client_secret

what error do you get when you do this


Same response when 3 params