Пример #1
0
        async void HandleAuthCallback(string code)
        {
            var model        = DataContext as MainModel;
            var grantType    = API.OAuth.Token.GrantType.authorization_code;
            var redirectUri  = model.OAuth_Authentication.RedirectUrl.Value;
            var clientId     = model.OAuth_Authentication.ApplicationId.Value;
            var clientSecret = model.OAuth_Authentication.ApplicationSecret.Value;
            var request      = new API.OAuth.Token.Request(grantType, redirectUri, clientId, clientSecret, code: code);
            var response     = await client.SendRequestAsObjectAsync <API.OAuth.Token.Response>(request);

            model.OAuth_Authentication.AccessToken.Value  = response.AccessToken;
            model.OAuth_Authentication.RefreshToken.Value = response.RefreshToken;
        }
Пример #2
0
        async void OAuth_RefreshAccessTokenButton_Click(object sender, RoutedEventArgs e)
        {
            var model        = DataContext as MainModel;
            var grantType    = API.OAuth.Token.GrantType.refresh_token;
            var redirectUri  = model.OAuth_Authentication.RedirectUrl.Value;
            var clientId     = model.OAuth_Authentication.ApplicationId.Value;
            var clientSecret = model.OAuth_Authentication.ApplicationSecret.Value;
            var refreshToken = model.OAuth_Authentication.RefreshToken.Value;
            var request      = new API.OAuth.Token.Request(grantType, redirectUri, clientId, clientSecret, refreshToken: refreshToken);
            var response     = await client.SendRequestAsObjectAsync <API.OAuth.Token.Response>(request);

            model.OAuth_Authentication.AccessToken.Value  = response.AccessToken;
            model.OAuth_Authentication.RefreshToken.Value = response.RefreshToken;
        }