Forum Academy Marketplace Showcase Pricing Features

Parsing a code from a callback URI on bubble

I have got the following flow working with spotify based on OAUTH2, but currently I have to manually pass some data to get it to work:

  1. I get the user to approve access on spotify by having the user visit the following url:
    https://accounts.spotify.com/authorize?client_id=#redacted#&response_type=code&redirect_uri=#bubble app uri goes here#&scope=user-top-read

  2. This returns the user to the callback uri with a code

#bubble callback uri#&code=AQCVs_U96kUcIKdZhsfUoOHyJ5FD8Cem-SeSvvdKyLsTVHey7RzG8pTurHruQZMyrhftoxhSUKhD6tQXpK1a2gz-Rb2LJ_GFgD7d5IY_apzF5jDgs753A6fNIoqiwkoZjvn6lYuwysB0Tymuk3PclVeOW3_WzrnicqHe2SBlZ0DxQrRzF4z6mtQWexbCAAE2cf2HQDynBrnxTi6itscSZvoDgm_vFOYkQlFajx-oLfQhTtFzNQ

  1. I make a post request to spotify using the code and some other params (client id, client secret etc) to get the access token / refresh token

  2. I am able to make api calls using the spotify app

This all works fine, but the problem is that currently I manually have to take the code returned in the callback uri (step 2) and pass it to my post request (step 3). Is there a way for bubble to parse the string from the callback uri and automatically handle this?

I attach a screenshot of my Oauth2 custom token settings:

Thank you,

Code is a parameter…you can extract it with dynamic expression for Get Data From URL and then specify the parameter as ‘code’…use that as the value you put into step 3

2 Likes

Thanks @boston85719, this did the trick!

1 Like