PSSpotify
PSSpotify copied to clipboard
Invalid refresh token when executing Connect-Spotify
When trying to connect to spotify I get the following Error:
Invoke-RestMethod : {"error":"invalid_grant","error_description":"Invalid refresh token"}
At C:\Program Files\WindowsPowerShell\Modules\PSSpotify\0.0.0.9\Modules\OAuth.psm1:83 char:30
+ $Authorization = Invoke-RestMethod -Uri $TokenEndpoint `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-Rest
Method], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMet
hodCommand
Invoke-RestMethod : {
"error": {
"status": 400,
"message": "Only valid bearer authentication supported"
}
}
At C:\Program Files\WindowsPowerShell\Modules\PSSpotify\0.0.0.9\Modules\Profile.psm1:30 char:20
+ $Profile = Invoke-RestMethod -Headers $Session.Headers `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-Rest
Method], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMet
hodCommand
The token must be valid because I just requested it from spotify with the following Powershell Script:
$uri = "https://accounts.spotify.com/api/token"
$headers = @{
"Content-Type" = "application/x-www-form-urlencoded"
}
$body = @{
grant_type = "client_credentials"
client_id = "5115e00240e545779e7100d2af23009e"
client_secret = "96bc20d578e74f9d98ab35b24ca6dff7"
}
$response = Invoke-RestMethod -Uri $uri -Method POST -Headers $headers -Body $body
After I got the token I tried to run these to connect to spotify:
Connect-Spotify -ClientIdSecret $Credentials -RefreshToken $response.access_token -KeepCredential
And
Connect-Spotify -ClientIdSecret $Credentials -RefreshToken $response -KeepCredential
Both didn't work.
For Context, my App settings on Spotify look like this:
And I get the Credentials with this command:
$Credentials = Get-Credential
Am I doing something wrong or is it a bug?