jwilsson / spotify-web-api-php

A PHP wrapper for Spotify's Web API.
MIT License
868 stars 156 forks source link

Uncaught SpotifyWebAPI\SpotifyWebAPIAuthException: Invalid redirect URI #236

Closed Klubuntu closed 3 years ago

Klubuntu commented 3 years ago

I'm try to use api token from

https://github.com/jwilsson/spotify-web-api-php/blob/main/docs/examples/access-token-with-authorization-code-flow.md

Unfortunately, it doesn't work well because it gets such and get this error

Fatal error: Uncaught SpotifyWebAPI\SpotifyWebAPIAuthException: Invalid redirect URI in D:\Software\Development\XAMPP\htdocs\spotif\auth\vendor\jwilsson\spotify-web-api-php\src\Request.php:56 Stack trace: #0 D:\Software\Development\XAMPP\htdocs\spotif\auth\vendor\jwilsson\spotify-web-api-php\src\Request.php(244): SpotifyWebAPI\Request->handleResponseError('{"error":"inval...', 400) #1 D:\Software\Development\XAMPP\htdocs\spotif\auth\vendor\jwilsson\spotify-web-api-php\src\Request.php(112): SpotifyWebAPI\Request->send('POST', 'https://account...', 'client_id=48f0c...', 'HTTP/2 400 \r\nda...') #2 D:\Software\Development\XAMPP\htdocs\spotif\auth\vendor\jwilsson\spotify-web-api-php\src\Session.php(250): SpotifyWebAPI\Request->account('POST', '/api/token', Array, Array) #3 D:\Software\Development\XAMPP\htdocs\spotif\auth\app\check.php(26): SpotifyWebAPI\Session->requestAccessToken('AQA9X84L0SDucXG...', 'a86937efa85589a...') #4 {main} thrown in D:\Software\Development\XAMPP\htdocs\spotif\auth\vendor\jwilsson\spotify-web-api-php\src\Request.php on line 56

I checked if the Redirect URI agrees in the Spotify Console and everything is set the same, what can i can change?

jwilsson commented 3 years ago

Hey! Try removing/adding the redirect URI again or create a brand new app. Sometimes the URIs seems to get messed up and starting over solves it. If not, come back here and post the code you're using (be sure to remove your client ID and secret) and we'll take it from there!