Пример #1
0
        private void buttonGetAccessToken_Click(object sender, EventArgs e)
        {
            this.buttonGetAccessToken.Enabled = false;

            string[] scopes = new[]
            {
                "playlist-read-private",
                "playlist-read-collaborative",
                "user-read-playback-state",
                "user-modify-playback-state"
            };

            AuthorizeApi authorizeApi = new AuthorizeApi();

            this.initialState = Guid.NewGuid().ToString();
            this.authorizeUri = authorizeApi.GetAuthorizeUri(
                clientId: this.textBoxClientId.Text,
                responseType: "code",
                redirectUri: this.textBoxRedirectUri.Text,
                state: this.initialState,
                scope: string.Join(" ", scopes));

            this.redirectUri = new Uri(this.textBoxRedirectUri.Text);

            this.textBoxUrl.Text = this.authorizeUri.ToString();
            this.webBrowser.Navigate(this.authorizeUri);
        }
        public void SetUp()
        {
            _fixtue        = new Fixture();
            _currentSecret = Environment.GetEnvironmentVariable("JWT_SECRET");
            _currentGroups = Environment.GetEnvironmentVariable("ALLOWED_USER_GROUP");
            _testSecret    = _fixtue.Create <string>();
            _testGroup     = _fixtue.Create <string>();
            Environment.SetEnvironmentVariable("JWT_SECRET", _testSecret);
            Environment.SetEnvironmentVariable("ALLOWED_USER_GROUP", _testGroup);

            _handler = new JwtSecurityTokenHandler();
            _subject = new AuthorizeApi();
        }