Пример #1
0
        public async Task Connect()
        {
            try
            {
                if (!HasInitialConfig())
                {
                    return;
                }

                ImplictGrantAuth auth = new ImplictGrantAuth(
                    _botConfig.SpotifyClientId,
                    _botConfig.SpotifyRedirectUri,
                    _botConfig.SpotifyServerUri,
                    Scope.UserReadCurrentlyPlaying
                    | Scope.UserReadPlaybackState
                    | Scope.UserModifyPlaybackState);

                auth.AuthReceived += OnAuthReceived;
                auth.Start();
                auth.OpenBrowser();
            }
            catch (Exception ex)
            {
                await _errHndlrInstance.LogError(ex, "TwitchBotApplication", "Connect()", false);
            }
        }
        private static void AuthorizeUser()
        {
            ImplictGrantAuth auth =
                new ImplictGrantAuth(Settings.ClientID, "http://localhost:4002", "http://localhost:4002", Scope.UserReadRecentlyPlayed | Scope.PlaylistModifyPrivate | Scope.PlaylistReadPrivate | Scope.PlaylistModifyPublic);

            auth.AuthReceived += OnAuthReceived;
            auth.Start();
            auth.OpenBrowser();
            Thread.Sleep(-1);
        }
Пример #3
0
        public SpotifyClient()
        {
            _factory = new ImplictGrantAuth(
                "f481e5ffbceb47a9aa8032cd37ea9b15",
                "http://localhost:8000",
                "http://localhost:8000",
                Scope.UserReadPrivate);

            _factory.AuthReceived += Factory_AuthReceived;
        }
Пример #4
0
        private void OnAuthReceived(object sender, Token token)
        {
            ImplictGrantAuth auth = (ImplictGrantAuth)sender;

            auth.Stop();

            _spotify = new SpotifyWebAPI
            {
                AccessToken = token.AccessToken,
                TokenType   = token.TokenType
            };
        }