Пример #1
0
        public bool GetAuthorization()
        {
            Task <bool> authorizationTask = new Task <bool>(GetAuthorizationResponse);

            authorizationTask.Start();

            //TODO: Evaluate whether this can be removed entirely.
            System.Threading.Thread.Sleep(1000);

            AuthorizationParameters authorizationParameters = new AuthorizationParameters
            {
                ClientID     = Credentials.SoundAtlasClientID,
                ResponseType = "code",
                RedirectUri  = Credentials.SoundAtlasRedirectURL,
                State        = "profile",
                Scope        = Scope.PlaylistModifyPrivate | Scope.PlaylistModifyPublic | Scope.PlaylistReadPrivate | Scope.PlaylistReadCollaborative
            };

            String authorizeUrl = Endpoints.GetAuthorize(authorizationParameters);

            System.Diagnostics.Process.Start(authorizeUrl);

            authorizationTask.Wait();

            return(authorizationTask.Result);
        }
Пример #2
0
        /// <summary>
        /// Example URL: https://accounts.spotify.com/authorize/?client_id=f78ea8ee8a054d56a6a90214a57ad830&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8000
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="redirectUri"></param>
        /// <returns></returns>
        public static String GetAuthorize(AuthorizationParameters authorizationParameters)
        {
            String scopeString = authorizationParameters.Scope.GetParameterNameAttribute <Spotify.Enums.Scope>(" ");

            return(String.Format(AuthorizeEndpoint, authorizationParameters.ClientID, authorizationParameters.ResponseType,
                                 HttpUtility.UrlEncode(authorizationParameters.RedirectUri), authorizationParameters.State, scopeString, authorizationParameters.ShowDialog));
        }
Пример #3
0
        public String GetAuthorizationUrl()
        {
            AuthorizationParameters authorizationParameters = new AuthorizationParameters
            {
                ClientID     = Credentials.SoundAtlasClientID,
                ResponseType = "code",
                RedirectUri  = Credentials.SoundAtlasRedirectURL,
                State        = "profile",
                Scope        = Scope.PlaylistModifyPrivate | Scope.PlaylistModifyPublic | Scope.PlaylistReadPrivate | Scope.PlaylistReadCollaborative | Scope.UserFollowRead | Scope.UserFollowModify
            };

            String authorizeUrl = Endpoints.GetAuthorize(authorizationParameters);

            return(authorizeUrl);
        }
Пример #4
0
        /// <summary>
        /// Example URL: https://accounts.spotify.com/authorize/?client_id=f78ea8ee8a054d56a6a90214a57ad830&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8000
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="redirectUri"></param>
        /// <returns></returns>
        public static String GetAuthorize(AuthorizationParameters authorizationParameters)
        {
            String scopeString = authorizationParameters.Scope.GetParameterNameAttribute<Spotify.Enums.Scope>(" ");

            return String.Format(AuthorizeEndpoint, authorizationParameters.ClientID, authorizationParameters.ResponseType,
                HttpUtility.UrlEncode(authorizationParameters.RedirectUri), authorizationParameters.State, scopeString, authorizationParameters.ShowDialog);
        }