Search code examples
wordpressapioauth-2.0spotifywordpress-plugin-creation

Oauth what redirect uri for wordpress plugin


I am creating a free wordpress plugin that interacts with the Spotify API. Users can download it, install it in their websites, activate it and they can then get specific information about a track.

Everything works in the v1 version. However i have trouble with the redirect uri.

I have to specify a specific redirect uri with Spotify, however the redirect differs on every instal, since its a different domain.

Should I redirect everything to a domain that i own, and redirect from there? Is there a way to have a dynamic redirect uri? Is there another method i dont know?

Please help!


Solution

  • I managed to fix this using a fixed redirect uri and the state parameter. Every Oauth authorization is sent to the same redirect uri, which is a domain that I control.

    I added the domain which the Oauth originated from to the state parameter. From that point i am able to redirect the user back to the orignal domain. This whole proces goes so fast that it feels like a dynamic redirect URI, but in reality it is not.