bmsimons / dotnet-core-spotify-authentication

A simple .NET core authentication platform for Spotify apps.
14 stars 13 forks source link

Can't get this to work #1

Open freke70 opened 6 years ago

freke70 commented 6 years ago

I think I'm not understanding something in your guide.

I have created an app on spotify. I have an ID and secret.

I also have a response from Spotify with an access token and a refresh token. I have added these to the psm1 file

How exactly do I get the Bearer token? Do I type in the ID and secret next to eachother on the right window on this site: http://www.utilities-online.info/base64/ And select "encode"?

Thanks for your help and for making the tool!

error in PS:

+ ...   $Result = Invoke-RestMethod -Uri "https://accounts.spotify.com/api/ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExceptio 
   n
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
bmsimons commented 6 years ago

Thanks for reaching out to me, I have made a commit that should make it easier to get your bearer token. https://imgur.com/a/MJahL

^ As shown in this screenshot, once you have authenticated in your browser, you'll get your basic bearer printed in the console. You should paste this inside the psm1 file, together with the refresh token shown in your browser response.

I hope this helps you out. 👍

gahs7 commented 6 years ago

Hi,

First off, great job much appreciated! I also have som problems with the module and thought I would reach out for some help. I downloaded you dotnet core application and fetched the bearer and refresh token. Inserted them into the psm1 file. Importing the module went well but when i try out the different functions I get the same error;

Invoke-RestMethod : { "error" : { "status" : 401, "message" : "Permissions missing" } } At C:\Users\ps-spotify\Public\Set-SpotifyConnectPause.ps1:28 char:5

Do I need to pass something else in the scope, such as "user-read-playback-state"? Or do you have any clue to why I get the error?

kvn1351 commented 6 years ago

I have the same issue. I guess that the scope isn't wide enough.

Edit: I got it to work by extending the scope.

https://github.com/bmsimons/dotnet-core-spotify-authentication/blob/f0b25cfa178b3e2c9336ff060772d82867c32095/Controllers/SpotifyController.cs#L30

https://developer.spotify.com/documentation/general/guides/scopes/

I seriously don't get how @bmsimons got a working token, with the right permissions, by using user-read-private and user-read-email; nor do I understand why those two were used in the first place.

Maybe it's just a proof of concept?

djansen1987 commented 5 years ago

Hi, I think i really going to enjoy your library so therefor already thanks.

Only issue i run in to setting it up is that .net sdk core 2.0 is end of life and the current version does not seem to work. Am i doing something wrong ?

PS C:\Windows\system32> Set-Location D:\software\Scripts\dotnet-core-spotify-authentication

PS D:\software\Scripts\dotnet-core-spotify-authentication> dotnet run D:\software\Scripts\dotnet-core-spotify-authentication\dotnet-core-spotify-authentication.csproj : error NU1202: Package Microsoft.AspNetCore.All 2.1.5 is not compatible with netcoreapp2.0 (. NETCoreApp,Version=v2.0). Package Microsoft.AspNetCore.All 2.1.5 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) dotnet : At line:1 char:1

  • dotnet run
  • 
    + CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

The build failed. Please fix the build errors and run again.

PS D:\software\Scripts\dotnet-core-spotify-authentication> dotnet --info .NET Core SDK (reflecting any global.json): Version: 2.2.401 Commit: 729b316c13

Runtime Environment: OS Name: Windows OS Version: 10.0.17763 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.2.401\

Host (useful for support): Version: 2.2.6 Commit: 7dac9b1b51

.NET Core SDKs installed: 2.2.401 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

lritter79 commented 4 years ago

I was able to resolve this issue by changing "netcoreapp2.0" to " netcoreapp2.1" in the CS proj file