示例#1
0
        static async Task RunAuthenticateVerificationCodeAsync(AppConfig appConfig)
        {
            string clientId         = appConfig.ClientId;
            string clientSecret     = appConfig.ClientSecret;
            string redirectUrl      = appConfig.RedirectUrl;
            string verificationCode = appConfig.VerificationCode;

            if (verificationCode == null)
            {
                Console.WriteLine("No verification code");
                return;
            }

            var oauthOptions      = new OAuthOptions(clientId, clientSecret, redirectUrl);
            var client            = new LaunchpadClient(oauthOptions);
            var accessTokenSource = await client.AuthenticateVerificationCodeAsync(verificationCode);

            var refreshToken = accessTokenSource.RefreshToken;

            Console.WriteLine($"Refresh token = {refreshToken}");

            var accessToken = await accessTokenSource.GetAccessTokenAsync();

            Console.WriteLine($"Access token = {accessToken}");
        }
示例#2
0
        static async Task RunAuthenticateCookieAsync(AppConfig appConfig)
        {
            string clientId     = appConfig.ClientId;
            string clientSecret = appConfig.ClientSecret;
            string redirectUrl  = appConfig.RedirectUrl;
            string cookie       = appConfig.BasecampCookie;
            string username     = appConfig.Username;

            if (cookie == null)
            {
                Console.WriteLine("No basecamp cookie");
                return;
            }

            var oauthOptions      = new OAuthOptions(clientId, clientSecret, redirectUrl);
            var client            = new LaunchpadClient(oauthOptions);
            var accessTokenSource = await client.AuthenticateCookieAsync(cookie, username);

            var refreshToken = accessTokenSource.RefreshToken;

            Console.WriteLine($"Refresh token = {refreshToken}");

            var accessToken = await accessTokenSource.GetAccessTokenAsync();

            Console.WriteLine($"Access token = {accessToken}");
        }