Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Invalid Access Code when using multiple scopes.

Solved!

Invalid Access Code when using multiple scopes.

 

Plan

Premium

Country

Ireland

 

 

 

My Question or Issue

 

When following the authorisation flow, everything works as expected if I use just one scope. E.g. 

scopes = 'user-read-currently-playing'
params={'scope':scopes, 'response_type':'code', 'redirect_uri':REDIRECT_URI, 'client_id':CLIENT_ID}).prepare().url 
 
- client visits this prepared url, gives access, and I get the following response back to my callback after sending the code I get from the client. 
 

{'access_token': 'BQCBQEcfGhdZEHZYQgZ1Ny8CAkzgqSwjTUIdbpnX8xSo1iOO8E4-aFPniPsjxtCwEgGQyUrxIAUyeSyobPYGaKwyRkM0j_GWzMBipPvX2EtpFdJYgXnNjzqxRjxGmC6QmdS_Mm4W22XWM_7p2AA', 'token_type': 'Bearer', 'expires_in': 3600, 'refresh_token': 'AQCm-7TngixLDTHLioOT44eu_mhpGdg0JhukvDLxtNvFC38y1FNJWZW7MQEbXp1DIZwBEx4n5XHaeEp4_Gb9jTUJBtFDFKqQPvB6Zq4NEapXxQ7frQrq9OvhqygjTBi0epw', 'scope': 'user-read-currently-playing'} 

 

- Perfect, I then can hit the currently-playing endpoint and get the details of the song that is playing. 

 

Now, I try to add extra permissions to my scope. For e.g. I follow the exact same steps but with the following: 

 

scopes = 'user-read-currently-playing streaming' 

 

I get this response to my callback 

{'access_token': 'BQBFNzQRjh5moOwY_pQSO8n8CwT0x_eJg79QztZKTmVaItbHo-eQSnM7uhjKSWeQeOmjGRO5y_zb78md6SiIxRe-kkHUpSYosU-yIxrba5DD-K4yZrptk_7n5B0Bm7jkb-GZqmoSowNwtLW3n8_URCM', 'token_type': 'Bearer', 'expires_in': 3600, 'refresh_token': 'AQAfCeI1FkPskXTDLlYSEcXuELHXr7Zv30J_oO_9DvHagmSOg25__fwhGMsY45B6Iyc1LmYiF-WNpmHN22A_-12giF1rW-EAz_AIsdD0ZK5VKL4_KsDLRUetGASWq4ygKNA', 'scope': 'streaming user-read-currently-playing'} 

Looks good to me? I have received permission to the scopes I requested. 

I try to hit the currently-playing endpoint again with this access code. This is the response

{'error': {'status': 401, 'message': 'Invalid access token'}} 

 

I have deleted apps, made new ones, tried different combinations of scopes. Nothing is working and I cannot figure it out. Any help is appreciated. Thanks

 

 

 

 

 

 

 

 

Reply

Accepted Solutions
Marked as solution

Oh my god. I was standing in the kitchen eating an apple and I had an epiphany. I had a max chars parameters on the access_token field in my django model. And yep - with certain scopes added the access token was longer than 150, and so I was cutting off the last few characters. that was the worst saturday of my life 

 

over and out. 

 

View solution in original post

1 Reply
Marked as solution

Oh my god. I was standing in the kitchen eating an apple and I had an epiphany. I had a max chars parameters on the access_token field in my django model. And yep - with certain scopes added the access token was longer than 150, and so I was cutting off the last few characters. that was the worst saturday of my life 

 

over and out. 

 

Suggested posts

Type a product name