API Help Much Appreciated

Hi,

I have successfully tested an API in an API tester, but it does not work from Bubble.

I am trying to set up a call for Spotify’s “Client Credentials Flow” authorization.

https://developer.spotify.com/documentation/general/guides/authorization-guide/

(I already have the Authorization Code setup working fine using Bubble’s built-in Oauth2 tools. However, I can not get client credentials flow to work with any of Bubble’s built-in Oauth tools. If anyone knows how to use those, I would much appreciate it)

Here is the call set up in APITester, which works fine

However, then this does not work in Bubble

I get a weird error message containing alot of HTML. (In other words the error message is a web page)

Any advice on setting up this call properly, or just using Bubble’s built in Oauth to handle this client credentials flow would be greatly appreciated!

Rob

Also

You should use the oAuth2 user agent in the authorization part of the Connector.
Authorize url: https://accounts.spotify.com/authorize
token url: https://accounts.spotify.com/api/token
user url: https://api.spotify.com/v1/me
email field will be email and id field will be id
I didn’t test, but try this and check. Don’t forget to set correct scope.

Hi Jici,

Yes I’ve already set up user agent authorization.

I’m trying to set up the client credentials flow which will allow users to use the Spotify API even if they do not have a Spotify account.

Thank you

Rob

May be because it wants the parameters encoded in a different way … add

Content-Type = application/x-www-form-urlencoded

And put the parameter in the body not in the parameter fields/

Thank you for the suggestion Nigel

This did not seem to work

Have you base64 encoded the client id and client secret ?

Yes,

Thank you

This call is working from the API tester, so I know the info is correct.

I tested the setting with a request bin and the connector continue to send as application/json. There’s a lot of strange thing with api connector that I have exposed a moment ago in another post. I will tey to find it and check if I provide a solution

This worked …

4 Likes

Nigel,

Amazing.

How creative.

Let me test this now.

Rob

Hi Nigel!

Amazing

This worked for me too:

Hi Nigel,

Thank you very much again for you amazing help,

I took your work, and figured out how to use the Spotify “Client Credentials Flow” within the Bubble Oauth2 Custom Token system.

Here it is:

3 Likes

Hey guys ! I know it’s been some time since the last answer on this post, but I’m encountering a similar issue, and was wondering if you could help !

I’m trying to use the Qencode transcoding API (doc).

I’m stuck on /v1/start_encode2 part.

The call is supposed to be made with this format : application/x-www-form-urlencoded

However, there are a lot of child parameters, and I’m not sure how I should format them in the API Connector.

I’ve tried importin the call via cURL, but it’s not working.

Then, I’ve tried to format in in JSON while having Content-Type = application/x-www-form-urlencoded

Here’s how I setup my call :


The thing is it doesnt detect my task_token parameters, as mentioned in this error :

Therefore, i’ve tried the solution you gave, which resulted in it detecting the task_token :


However, i’m not sure how I should pass the query parameter with all its children parameters.

```
curl https://api.qencode.com/v1/start_encode2 \  
 -d task_token=b49e034d198262f1d5d15ed9f3cb8 \  
 -d payload="12345" \  
 -d query='{"query": {  
     "source": "https://your-server.com/video.mp4",  
     "format": [  
       {  
         "output": "mp4",  
         "destination": {  
           "url":"s3://s3.us-east-1.amazonaws.com/yourbucket/output.mp4",    
           "key":"abcde12345",    
           "secret":"abcde12345",    
           "permissions": "public-read"  
         },  
     "framerate": "29.97",  
     "keyframe": "25",  
     "size": "360x240",  
     "start_time": 10,  
     "duration": 20,  
     "audio_bitrate": 64 
    } 
   ] 
  } 
 }'
```

Do you have any idea on how I could implement this ? @NigelG @Jici

Thanks for your help !

Okay, I may have found where the issue is coming from. In the doc they say :

Pass the task_token with the /v1/start_encode2 method, along with the query JSON object containg the request with your transcoding parameters.

If I’m not mistaken, this means that I should pass the task_token as application/x-www-form-urlencoded and separetaly pass the Query (which is JSON), but I’ve no idea how I could do that :sweat_smile:

This API requiere you to send url parameters. Keep the task_token=<task_token>&payload=<payload>&query=<query>
The json will be set in the query parameters directly.
The only thing I’m not sure, is if Bubble will encode it or not in this case (I don’t remember, because the behavior is sometimes different if you use parameters or body).

If this doesn’t work, remove all body, and add 3 parameters instead: task_token, query and payload

For the “dynamic” part of the JSON, you can use arbitrary text and create the json directly in it and put the dynamic part in the action.

For the url, you may use :formatted as json-safe. Don’t forget that this action will add surrounding quotes

2 Likes

Amazing ! Thanks so much Jici, you made my day !

Here’s the solution in case other people have a similar issue :

Have a nice day Jici, thanks again !

2 Likes