예제 #1
0
        public async Task <IEnumerable <string> > Get()
        {
            string JIRA_BASE_URL = "https://sprintplanner.atlassian.net";
            var    config        = new TinyOAuthConfig
            {
                RequestTokenUrl   = JIRA_BASE_URL + "/plugins/servlet/oauth/request-token",
                AuthorizeTokenUrl = JIRA_BASE_URL + "/plugins/servlet/oauth/authorize",
                AccessTokenUrl    = JIRA_BASE_URL + "/plugins/servlet/oauth/access-token",
                ConsumerKey       = "CONSUMER_KEY",
                ConsumerSecret    = "CONSUMER_SECRET"
            };

            // Use the library
            var tinyOAuth = new TinyOAuth(config);

            // Get the request token and request token secret
            var requestTokenInfo = await tinyOAuth.GetRequestTokenAsync();

            // Construct the authorization url
            var authorizationUrl = tinyOAuth.GetAuthorizationUrl(requestTokenInfo.RequestToken);

            // *** You will need to implement these methods yourself ***
            Process.Start(authorizationUrl); //, LaunchUriAsync(new Uri(authorizationUrl)) etc...
            //var verificationCode = await InputVerificationCodeAsync(authorizationUrl);

            // *** Important: Do not run this code before visiting and completing the authorization url ***
            //var accessTokenInfo = await tinyOAuth.GetAccessTokenAsync(requestTokenInfo.RequestToken, requestTokenInfo.RequestTokenSecret, verificationCode);
            return(new string[] { "value1", "value2" });
        }
예제 #2
0
        public async Task <string> GetAuthorizationUrlAsync()
        {
            _requestTokenInfo = await _tinyOAuth.GetRequestTokenAsync();

            var authorizationUrl = _tinyOAuth.GetAuthorizationUrl(_requestTokenInfo.RequestToken);

            return(authorizationUrl);
        }
예제 #3
0
        /// <summary>
        /// Returns the request token and secret from UpWork
        /// </summary>
        /// <returns></returns>
        public async Task <TokenResponse> GetRequestToken()
        {
            TokenResponse tokenResponse = new TokenResponse();
            // Set up the basic config parameters
            var config = new TinyOAuthConfig
            {
                AccessTokenUrl    = AccessTokenUrl,
                AuthorizeTokenUrl = AuthorizeTokenUrl,
                RequestTokenUrl   = TokenUrl,
                ConsumerKey       = ApiCredentials.ConsumerKey,
                ConsumerSecret    = ApiCredentials.ConsumerSecret
            };

            // Use the library
            var tinyOAuth = new TinyOAuth(config);

            // Get the request token and request token secret
            tokenResponse.RequestToken = await tinyOAuth.GetRequestTokenAsync();

            tokenResponse.AuthorizationUrl = tinyOAuth.GetAuthorizationUrl(tokenResponse.RequestToken.RequestToken + this.GenerateCallback());

            return(tokenResponse);
        }