Search code examples
pythonspotify

Creating a Code Challenge for Spotify API PKCE, Why Is It Not In Byte Form?


I am not sure if i can ask about the Spotify API but saw no other subreddit to put in. I am trying to connect to Spotify API without the use of external packages (like Spotipy).

I am reading their documentation here:

I decided to use the PKCE since I want to distribute a software and the user only needs to give their client_id (its open source)

In that case, I need to create a "code challenge", this is what I have:

SpotifyCodeChallenge = base64.b64encode(hashlib.sha256(SpotifyCodeVerifier.encode()))

Yet this is the error I get:

image here

How would I fix this?


Solution

  • SpotifyCodeChallenge = base64.b64encode(hashlib.sha256(SpotifyCodeVerifier.encode('utf-8')).digest())
    

    This will prob do it.