Announcements

Help Wizard

Step 1

NEXT STEP

The callback url makes the url with hash instead of querystring

The callback url makes the url with hash instead of querystring

Hi, following this docs:

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

 

The flow works well, but is returning back with a hash:

http://localhost:5000/callback#access_token=BQDt7fHXta65b...

 

Instead of a queryString:

http://localhost:5000/callback?access_token=BQDt7fHXta65b...

 

 

Am I doing something wrong?

Reply
3 Replies

Hey @Josenzo, thanks for reaching out!

 

Hmm, I've taken a look and it seems that this is expected behaviour.

 

"If the user grants access, the final URL will contain a hash fragment with the following data encoded as a query string. For example: 

https://example.com/callback#access_token=NwAExz...BV3O2Tk&token_type=Bearer&expires_in=3600&state=123"

 

Note: a query string will be returned when the user denies access.

 

Check this out for more information: https://developer.spotify.com/documentation/general/guides/authorization-guide/#1-have-your-applicat...

 

Let me know if you have any questions! 🙂

 

Have a good one,

Hubo

HuboSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Can you share how access_token is accessed from the url.

In my case I'm using django, so I have a view as follows

```

def callback(request, format=None😞
    print(request.GET)

    if "access_token" in request.GET:
    print(request.GET["access_token"])

return HttpResponse("Callback Recieved")
```
 
But my request.GET is empty dictionary everytime.
And when I try to build the absolute url (which you can do from request), I get just http://localhost:8000/callback/ with no params and extra data

Spotify has four authorization methods. The Implicit Grant Flow encodes data in the hash fragment. The Authorization Code Flow encodes data in the query string.

Suggested posts