SpotifyAPI-NET icon indicating copy to clipboard operation
SpotifyAPI-NET copied to clipboard

Working Auth Code?

Open renenienaber opened this issue 8 years ago • 3 comments

Does anybody has an working Authorization Code for me? Doesn't matter which Auth but ImplicitGrantAuth doesn't work for me (#304 ).

I just want to have access to the spotify music informations.

Doesn't matter if the code is in C# but I would prefer VB.NET-Code because I use this in my project as well.

Greets.

renenienaber avatar Oct 30 '18 20:10 renenienaber

private AuthorizationCodeAuth auth;

public void Authentication()
        {
            auth = new AuthorizationCodeAuth("CLIENTID", "CLIENTSECRET",
               "http://localhost:8000", "http://localhost:8000", // Set currect port
    Scope.PlaylistReadPrivate | Scope.UserLibraryRead | Scope.UserReadPrivate
               | Scope.UserLibraryModify | Scope.UserFollowRead | Scope.UserFollowModify | Scope.PlaylistModifyPrivate
               | Scope.PlaylistModifyPublic | Scope.UserModifyPlaybackState | Scope.UserReadPlaybackState);

            auth.Start();
            auth.OpenBrowser();
            auth.AuthReceived += auth_OnResponseReceivedEvent;          
        }

public void auth_OnResponseReceivedEvent(object sender, AuthorizationCode payload)
        {
            AuthorizationCode authCode = payload;           
            Token token = auth.ExchangeCode(authCode.Code).Result;
            
            if (auth != null)
            {
                spotify = new SpotifyWebAPI()
                {
                    TokenType = token.TokenType,
                    AccessToken = token.AccessToken
                };
            }           
            auth.Stop();
        }

Hope this helps.

Gruhlum avatar Nov 22 '18 23:11 Gruhlum

Hope this helps.

It works!! Finally! Big big thank you.

But a question left. I get a window like this: Pic 1 Pic 2 Pic 3

You get this too?

renenienaber avatar Nov 23 '18 10:11 renenienaber

May I ask you what your vb.net code looks like. I am having very large problems getting started as well. Many thanks, Bob

OneBobone avatar Mar 25 '19 10:03 OneBobone