javahttp-redirectoauth-2.0spotifyredirect-uri

Spotify APi Redirect URI with changed Parameters?


I am currently using the Spotify APi. The request URL from which the authentication originates is http://localhost:8080/app/9 The 9 is the parameter for the respective ID of the user.

The callback URL is also entered in Spotif Developer: http://localhost:8080/app/?

I now get the error message: INVALID_CLIENT: Invalid redirect URI

I am aware that this is due to the changed CallbackURi. The question now. How do I create a wildcard for the parameter in the URI?

Thanks for your help.


Solution

  • Lack of understanding made me think that the userID must be included in the callback URI. However, this would not only be a security issue, but it also doesn't work because the callback URI has to be static.

    So I decided to solve the problem with session cookies. Now i save a cookie with a session id and the userID when the user first enters the page after logging in.

    If the user comes back to the site after the oAuth2 authentication, I use the session cookie that is cached.