Exemplo n.º 1
0
        public async Task <OAuth2TokenResult> CreateOAuthCredentialsAsync(Uri targetUri)
        {
            var oauthClient = new BitbucketOAuth2Client(HttpClient, Context.Settings);

            var browserOptions = new OAuth2WebBrowserOptions
            {
                SuccessResponseHtml       = BitbucketResources.AuthenticationResponseSuccessHtml,
                FailureResponseHtmlFormat = BitbucketResources.AuthenticationResponseFailureHtmlFormat
            };

            var browser        = new OAuth2SystemWebBrowser(browserOptions);
            var authCodeResult = await oauthClient.GetAuthorizationCodeAsync(Scopes, browser, CancellationToken.None);

            return(await oauthClient.GetTokenByAuthorizationCodeAsync(authCodeResult, CancellationToken.None));
        }
Exemplo n.º 2
0
        public async Task <OAuth2TokenResult> RefreshOAuthCredentialsAsync(string refreshToken)
        {
            var oauthClient = new BitbucketOAuth2Client(HttpClient, Context.Settings);

            return(await oauthClient.GetTokenByRefreshTokenAsync(refreshToken, CancellationToken.None));
        }