Skip to content
Advertisement

Spotify PKCE. Error invalid client secret

I need to complete Authorization Code Flow with Proof Key for Code Exchange. In step 4, I get an error 400 - bad request {"error":"invalid_request","error_description":"Invalid client secret"}.

Why need to client secret if it is PKCE. What do I wrong? Do you have any idea?

Body request like

code=abc&grant_type=authorization_code&redirect_uri=spotify-sdk%3A%2F%2Fauth&client_id=abc&code_verifier=abc

Example code verifier: xeJ7Sx1lyUr0A_DAomzewuGn8vNS2cd3ZF2odDlqHEqeYKpxjnYYhpHxOohoo7lf22VNImGiOy_PE07owmDn2VmTWvdKKQ

Example code challenge: N_yPRc_VC8JQJz5dYOuvvM-9cJLdAtEjJ9-lh8Xk_qI

And the same I see into request.

Step 1

Use PkceUtil class

JavaScript

Step 2

Use official android-sdk auth-lib by Spotify

JavaScript

Step 3 and 4

Get code and send request to exchange it

JavaScript

In order to send request use own AuthApi and AuthService with help Retrofit

JavaScript

Advertisement

Answer

I’m not familiar with Spotify Android SDK library, but judging by this issue, it does not support PKCE authentication flow and I’m not sure if it creates a valid request when you set custom code_challenge and code_challenge_method parameters.

Make sure that this step (2) works, as otherwise the authorization endpoint assumes that you use the normal Authorization Code Flow and expects a client_secret (in step 4).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement