Exemple #1
0
        /// <summary>
        ///     Gets the response from VATSIM SSO.
        /// </summary>
        /// <param name="oauthRequest">
        ///     The <see cref="OAuthRequest"/>.
        /// </param>
        /// <returns>
        ///     The <see cref="IReponse"/>.
        /// </returns>
        private static IReponse GetSSOResponse(OAuthRequest oauthRequest)
        {
            // Get the auth query
            string auth = oauthRequest.GetAuthorizationQuery();

            // Create the web request and add auth query to the url
            string         url     = oauthRequest.RequestUrl + '?' + auth;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            // Get the response
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            string          json     = string.Empty;

            using (StreamReader responseStream = new StreamReader(response.GetResponseStream())) json = responseStream.ReadToEnd();

            // Deserialize the JSON string into an IResponse and account for the date time formatting
            IReponse data = JsonConvert.DeserializeObject <IReponse>(json, new IsoDateTimeConverter {
                DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
            });

            if (data != null)
            {
                data.Raw = json;
            }

            return(data);
        }
Exemple #2
0
        public async Task <AuthTokenInfo> GetAuthTokens()
        {
            var authRequest = new OAuthRequest
            {
                Method          = "GET",
                CallbackUrl     = CallbackUrl,
                Type            = OAuthRequestType.RequestToken,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ConsumerKey     = ConsumerKey,
                ConsumerSecret  = ConsumerSecret,
                RequestUrl      = RequestTokenUrl,
                Version         = OAuthVersion
            };

            try
            {
                var request = await(authRequest.RequestUrl + "?" + authRequest.GetAuthorizationQuery()).GetAsync();
                var result  = await request.Content.ReadAsStringAsync();

                var tokens = result.Split('&').Select(x => x.Split('=')).ToDictionary(split => split[0], split => split[1]);
                return(new AuthTokenInfo(AuthorizeUrl)
                {
                    OAuthToken = tokens["oauth_token"], OAuthTokenSecret = tokens["oauth_token_secret"]
                });
            }
            catch (FlurlHttpException ex)
            {
                throw new UnauthorizedQuickBooksClientException(
                          "QuickBooks returned with an unauthorized response. Be sure your consumer key and consumer secret are correct.",
                          ex.InnerException);
            }
        }
Exemple #3
0
        public void verifyUrl(string url)
        {
            var          qsParams = HttpUtility.ParseQueryString(url);
            var          token    = qsParams.Get("oauth_token");
            var          verifier = qsParams.Get("oauth_verifier");
            OAuthRequest client   = new OAuthRequest()
            {
                Method          = "GET",
                Type            = OAuthRequestType.AccessToken,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ConsumerKey     = this.consumerKey,
                ConsumerSecret  = this.consumerSecret,
                RequestUrl      = "https://api.shapeways.com/oauth1/access_token/v1",
                Version         = "1.0a",
                Realm           = "shapeways.com",
                TokenSecret     = this.OAuthSecret,
                Token           = token,
                Verifier        = verifier,
            };
            string          auth       = client.GetAuthorizationQuery();
            string          requestUrl = client.RequestUrl + "?" + auth;
            HttpWebRequest  request    = (HttpWebRequest)WebRequest.Create(requestUrl);
            HttpWebResponse response   = (HttpWebResponse)request.GetResponse();
            string          content    = new StreamReader(response.GetResponseStream()).ReadToEnd();
            var             result     = HttpUtility.ParseQueryString(content);

            this.OAuthToken  = result.Get("oauth_token");
            this.OAuthSecret = result.Get("oauth_token_secret");
        }
        public static OauthToken GetRequestToken(string baseUrl, AvansOauthHelperOptions options)
        {
            // Creating a new instance with a helper method
            OAuthRequest client = OAuthRequest.ForRequestToken(options.AvansClientId, options.AvansSecret);

            client.RequestUrl  = "https://publicapi.avans.nl/oauth/request_token";
            client.CallbackUrl = baseUrl + "/api/account/AvansCallback";

            // Using URL query authorization to get the request token
            string auth     = client.GetAuthorizationQuery();
            var    url      = client.RequestUrl + "?" + auth;
            var    request  = (HttpWebRequest)WebRequest.Create(url);
            var    response = (HttpWebResponse)request.GetResponse();

            Stream       receiveStream = response.GetResponseStream();
            StreamReader reader        = new StreamReader(receiveStream, Encoding.UTF8);
            string       body          = reader.ReadToEnd();

            //TY for the concistent response avans
            var uri = body.Replace("php&", "php?");

            uri = uri.Split("authentification_url=")[1];

            return(AvansOauthHelper.getTokenFormUri(uri));
        }
Exemple #5
0
        public String connect()
        {
            OAuthRequest client = new OAuthRequest()
            {
                Method          = "GET",
                Type            = OAuthRequestType.RequestToken,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ConsumerKey     = this.consumerKey,
                ConsumerSecret  = this.consumerSecret,
                RequestUrl      = "https://api.shapeways.com/oauth1/request_token/v1",
                Version         = "1.0a",
                Realm           = "shapeways.com",
                CallbackUrl     = this.callback,
            };
            string          auth     = client.GetAuthorizationQuery();
            string          url      = client.RequestUrl + "?" + auth;
            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            string          content  = new StreamReader(response.GetResponseStream()).ReadToEnd();
            var             result   = HttpUtility.ParseQueryString(content);
            var             authUrl  = result.Get("authentication_url");

            this.OAuthToken  = result.Get("oauth_token");
            this.OAuthSecret = result.Get("oauth_token_secret");
            response.Close();
            return(authUrl);
        }
        public IActionResult Callback()
        {
            // Read token and verifier
            string token    = Request.Query["oauth_token"];
            string verifier = Request.Query["oauth_verifier"];

            // Create access token request
            var client = new OAuthRequest
            {
                Method          = "GET",
                Type            = OAuthRequestType.RequestToken,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ConsumerKey     = ConsumerKey,
                ConsumerSecret  = ConsumerSecret,
                Token           = token,
                TokenSecret     = TokenSecret,
                RequestUrl      = RequestAccessTokenUrl,
                Verifier        = verifier
            };

            // Build request url and send the request
            var url      = client.RequestUrl + "?" + client.GetAuthorizationQuery();
            var request  = (HttpWebRequest)WebRequest.Create(url);
            var response = (HttpWebResponse)request.GetResponse();

            using var dataStream = response.GetResponseStream();
            var reader             = new StreamReader(dataStream);
            var responseFromServer = reader.ReadToEnd();

            // Parse and save access token and secret
            OAuthToken       = HttpUtility.ParseQueryString(responseFromServer).Get("oauth_token");
            OAuthTokenSecret = HttpUtility.ParseQueryString(responseFromServer).Get("oauth_token_secret");

            return(Ok());
        }
Exemple #7
0
        public static Dictionary <string, string> Login()
        {
            OAuthRequest request = new OAuthRequest();

            request.ConsumerKey    = _appKey;
            request.ConsumerSecret = _secret;
            request.Method         = "GET";
            request.RequestUrl     = requestURL;
            request.Version        = "1.0";
            request.Type           = OAuthRequestType.RequestToken;

            using (HttpClient client = new HttpClient())
            {
                var response = client.GetAsync(requestURL + "?" + request.GetAuthorizationQuery()).Result;
                Dictionary <string, string> returnValue = new Dictionary <string, string>();
                if (response.IsSuccessStatusCode)
                {
                    var queryParams = response.Content.ReadAsStringAsync().Result.Split('&');
                    foreach (var param in queryParams)
                    {
                        returnValue.Add(param.Split('=')[0], param.Split('=')[1]);
                    }
                }
                return(returnValue);
            }
        }
Exemple #8
0
        public static string GetAccessToken(string token, string tokenSecret, string verificationCode)
        {
            OAuthRequest request = new OAuthRequest();

            request.ConsumerKey    = _appKey;
            request.ConsumerSecret = _secret;
            request.Token          = token;
            request.TokenSecret    = tokenSecret;
            request.Verifier       = verificationCode;
            request.Method         = "GET";
            request.RequestUrl     = accessURL;
            request.Version        = "1.0";
            request.Type           = OAuthRequestType.AccessToken;

            using (HttpClient client = new HttpClient())
            {
                var    response    = client.GetAsync(accessURL + "?" + request.GetAuthorizationQuery()).Result;
                string returnValue = null;
                if (response.IsSuccessStatusCode)
                {
                    returnValue = response.Content.ReadAsStringAsync().Result;
                }
                return(returnValue);
            }
        }
        public IActionResult Login()
        {
            // Configure our OAuth client
            var client = new OAuthRequest
            {
                Method          = "GET",
                Type            = OAuthRequestType.RequestToken,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ConsumerKey     = ConsumerKey,
                ConsumerSecret  = ConsumerSecret,
                RequestUrl      = RequestUrl,
                CallbackUrl     = "https://localhost:5001/api/etsy/callback"
            };

            // Build request url and send the request
            var url      = client.RequestUrl + "?" + client.GetAuthorizationQuery();
            var request  = (HttpWebRequest)WebRequest.Create(url);
            var response = (HttpWebResponse)request.GetResponse();

            using var dataStream = response.GetResponseStream();
            var reader             = new StreamReader(dataStream);
            var responseFromServer = reader.ReadToEnd();

            // Parse login_url and oauth_token_secret from response
            var loginUrl = HttpUtility.ParseQueryString(responseFromServer).Get("login_url");

            TokenSecret = HttpUtility.ParseQueryString(responseFromServer).Get("oauth_token_secret");

            return(Redirect(loginUrl));
        }
Exemple #10
0
        public IActionResult Login()
        {
            var client = new OAuthRequest
            {
                Method          = "GET",
                Type            = OAuthRequestType.RequestToken,
                SignatureMethod = OAuth.OAuthSignatureMethod.HmacSha1,
                ConsumerKey     = ConsumerKey,
                ConsumerSecret  = ConsumerSecret,
                RequestUrl      = RequestUrl,
                CallbackUrl     = "https://localhost:44330/trelloauthorization/callback"
            };

            var url      = client.RequestUrl + "?" + client.GetAuthorizationQuery();
            var request  = (HttpWebRequest)WebRequest.Create(url);
            var response = (HttpWebResponse)request.GetResponse();

            using var dataStream = response.GetResponseStream();
            var reader             = new StreamReader(dataStream);
            var responseFromServer = reader.ReadToEnd();

            // Parse login_url and oauth_token_secret from response
            var OauthToken = HttpUtility.ParseQueryString(responseFromServer).Get("oauth_token");

            TokenSecret = HttpUtility.ParseQueryString(responseFromServer).Get("oauth_token_secret");

            return(Redirect("https://trello.com/1/OAuthAuthorizeToken?oauth_token=" + OauthToken + "&?expiration=1day&scope=read,write"));
        }
Exemple #11
0
        private static string GetRequestToken(string url)
        {
            OAuthRequest client = OAuthRequest.ForRequestToken(ConsumerKey, ConsumerSecret);

            client.RequestUrl      = url;
            client.Method          = "POST";
            client.SignatureMethod = OAuthSignatureMethod.HmacSha1;
            string urlRet = client.GetAuthorizationQuery();

            return(url + '?' + urlRet);
        }
Exemple #12
0
        private void connectCar2Go()
        {
            var car2GoGetTokenEndpoint = "https://www.car2go.com/api/reqtoken";
            var oauthRequest           = new OAuthRequest {
                CallbackUrl     = "oob",
                ConsumerKey     = FreeCarsCredentials.Car2Go.ConsumerKey,
                ConsumerSecret  = FreeCarsCredentials.Car2Go.SharedSecred,
                Method          = "GET",
                RequestUrl      = car2GoGetTokenEndpoint,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                Type            = OAuthRequestType.RequestToken,
                Version         = "1.0",
            };
            var requestParameters = oauthRequest.GetAuthorizationQuery();
            var requestUrl        = new Uri(car2GoGetTokenEndpoint + "?" + requestParameters, UriKind.Absolute);

            var webClient = new WebClient();

            webClient.DownloadStringCompleted += delegate(object client, DownloadStringCompletedEventArgs arguments) {
                string[] results = { };
                if (null != arguments.Error)
                {
                    return;
                }
                var authorizeUrl = new Uri("https://www.car2go.com/api/authorize?" + arguments.Result, UriKind.Absolute);
                results = arguments.Result.Split(new string[] { "&" }, StringSplitOptions.None);
                App.SetAppSetting("car2go.oauth_token_secret", results[1].Split(new char[] { '=' })[1]);
                App.SetAppSetting("car2go.oauth_request_token", results[0].Split(new char[] { '=' })[1]);
                //(string)IsolatedStorageSettings.ApplicationSettings["current_map_city"]
                if (App.IsCertified)
                {
                    c2gAuthBrowser.Dispatcher.BeginInvoke(() => {
                        c2gAuthBrowser.Visibility = Visibility.Visible;
                        c2gAuthBrowser.Navigate(authorizeUrl);
                    });
                }
                else
                {
                    verifierPanel.Visibility = Visibility.Visible;
                    var authBrowserTask = new WebBrowserTask {
                        Uri = authorizeUrl,
                    };
                    c2gScrollViewer.ScrollToVerticalOffset(c2gScrollViewer.ActualHeight);
                    authBrowserTask.Show();
                }
            };
            webClient.DownloadStringAsync(requestUrl);
        }
        public TwitterVerifyResult VerifyCredentials()
        {
            OAuthRequest oAuth = OAuthRequest.ForProtectedResource("GET", TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, Token, Secret);

            oAuth.RequestUrl = TWITTER_BASE_URL;
            var auth     = oAuth.GetAuthorizationQuery();
            var uri      = new Uri(oAuth.RequestUrl + auth);
            var client   = new HttpClient();
            var response = client.GetAsync(uri).Result;

            if (response.IsSuccessStatusCode)
            {
                var content = response.Content.ReadAsStringAsync().Result;
                return(JsonConvert.DeserializeObject <TwitterVerifyResult>(content));
            }
            return(null);
        }
        public static string GetUserInfo(AvansOauthHelperOptions options, OauthToken accesToken)
        {
            OAuthRequest client = OAuthRequest.ForProtectedResource("GET", options.AvansClientId, options.AvansSecret, accesToken.Token, accesToken.Secret);

            client.RequestUrl = "https://publicapi.avans.nl/oauth/people/@me";

            // Using URL query authorization to get the request token
            string auth     = client.GetAuthorizationQuery();
            var    url      = client.RequestUrl + "?" + auth;
            var    request  = (HttpWebRequest)WebRequest.Create(url);
            var    response = (HttpWebResponse)request.GetResponse();

            Stream       receiveStream = response.GetResponseStream();
            StreamReader reader        = new StreamReader(receiveStream, Encoding.UTF8);
            string       body          = reader.ReadToEnd();

            return(body);
        }
        public async Task <IActionResult> OpenOrders()
        {
            const string requestUrl = "https://openapi.etsy.com/v2/shops/YOURSHOPNAME/receipts/open?";

            var client = new OAuthRequest
            {
                Method          = "GET",
                Type            = OAuthRequestType.ProtectedResource,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ConsumerKey     = ConsumerKey,
                ConsumerSecret  = ConsumerSecret,
                Token           = OAuthToken,
                TokenSecret     = OAuthTokenSecret,
                RequestUrl      = requestUrl,
            };

            var url    = requestUrl + client.GetAuthorizationQuery();
            var result = await url.GetStringAsync();

            return(Content(result, "application/json"));
        }
Exemple #16
0
        /// <summary>
        /// Take this login URL and accept using logged in Etsy account to register this service. Also note your token secrets
        /// and add to your configuration.
        /// </summary>
        /// <returns></returns>
        public (string token, string tokenSecret, string loginUrl) Login()
        {
            var scopeEncoded = HttpUtility.UrlEncode("email_r listings_r listings_w transactions_r profile_r");

            // Configure our OAuth client
            var client = new OAuthRequest
            {
                Method          = "GET",
                Type            = OAuthRequestType.RequestToken,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ConsumerKey     = _auth.ConsumerKey,
                ConsumerSecret  = _auth.ConsumerSecret,
                RequestUrl      = TokenRequestUrl + $"?scope={scopeEncoded}"
                                  //CallbackUrl = "https://localhost:5001/api/etsy/callback"
            };

            //var scopeEncoded = HttpUtility.UrlEncode("email_r,listings_r,listings_w,transactions_r,billing_r,profile_r");


            // Build request url and send the request
            //var url = client.RequestUrl + client.GetAuthorizationQuery();
            var url      = client.RequestUrl + "&" + client.GetAuthorizationQuery();
            var request  = (HttpWebRequest)WebRequest.Create(url);
            var response = (HttpWebResponse)request.GetResponse();



            using var dataStream = response.GetResponseStream();
            var reader             = new StreamReader(dataStream);
            var responseFromServer = reader.ReadToEnd();

            // Parse login_url and oauth_token_secret from response
            var loginUrl    = HttpUtility.ParseQueryString(responseFromServer).Get("login_url");
            var tokenSecret = HttpUtility.ParseQueryString(responseFromServer).Get("oauth_token_secret");
            var token       = HttpUtility.ParseQueryString(responseFromServer).Get("oauth_token");

            return(token, tokenSecret, loginUrl);
        }
Exemple #17
0
        private void getC2GAccessToken(string[] tokenData)
        {
            var car2GoGetTokenEndpoint = "https://www.car2go.com/api/accesstoken";

            var oauthRequest = new OAuthRequest()
            {
                CallbackUrl     = "oob",
                ConsumerKey     = FreeCarsCredentials.Car2Go.ConsumerKey,
                ConsumerSecret  = FreeCarsCredentials.Car2Go.SharedSecred,
                Method          = "GET",
                RequestUrl      = car2GoGetTokenEndpoint,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                Token           = tokenData[0],
                TokenSecret     = (string)App.GetAppSetting("car2go.oauth_token_secret"),
                //TokenSecret = tokenData[1],
                Type     = OAuthRequestType.AccessToken,
                Verifier = tokenData[1],
                Version  = "1.0",
            };
            var requestParameters = oauthRequest.GetAuthorizationQuery();
            var requestUrl        = new Uri(car2GoGetTokenEndpoint + "?" + requestParameters, UriKind.Absolute);

            var webClient = new WebClient();

            webClient.DownloadStringCompleted += (client, arguments) => {
                if (null != arguments.Error)
                {
                    MessageBox.Show(Strings.SettingsPageCar2GoAuthFailed);
                    return;
                }
                var results = arguments.Result.Split(new char[] { '&' }, StringSplitOptions.None);
                App.SetAppSetting("car2go.oauth_token", results[0].Split(new char[] { '=' })[1]);
                App.SetAppSetting("car2go.oauth_token_secret", results[1].Split(new char[] { '=' })[1]);
                App.SetAppSetting("car2go.oauth_token_timestamp", DateTime.UtcNow);
                CheckCar2GoApiAccess();
            };
            webClient.DownloadStringAsync(requestUrl);
        }
        public static OauthToken GetAccesToken(AvansOauthHelperOptions options, OauthToken requestToken, string verifier)
        {
            // Creating a new instance with a helper method
            OAuthRequest client = OAuthRequest.ForAccessToken(options.AvansClientId, options.AvansSecret, requestToken.Token, requestToken.Secret);

            client.Verifier   = verifier;
            client.RequestUrl = "https://publicapi.avans.nl/oauth/access_token";

            // Using URL query authorization to get the request token
            string auth     = client.GetAuthorizationQuery();
            var    url      = client.RequestUrl + "?" + auth;
            var    request  = (HttpWebRequest)WebRequest.Create(url);
            var    response = (HttpWebResponse)request.GetResponse();

            Stream       receiveStream = response.GetResponseStream();
            StreamReader reader        = new StreamReader(receiveStream, Encoding.UTF8);
            string       body          = reader.ReadToEnd();

            //turn body into uri
            var uri = "http://temp?" + body;

            return(AvansOauthHelper.getTokenFormUri(uri));
        }
Exemple #19
0
        public object getApiInfo()
        {
            OAuthRequest client = new OAuthRequest()
            {
                Method          = "GET",
                Type            = OAuthRequestType.ProtectedResource,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ConsumerKey     = this.consumerKey,
                ConsumerSecret  = this.consumerSecret,
                RequestUrl      = "https://api.shapeways.com/api/v1",
                Version         = "1.0a",
                Realm           = "shapeways.com",
                TokenSecret     = this.OAuthSecret,
                Token           = this.OAuthToken,
            };
            string          auth       = client.GetAuthorizationQuery();
            string          requestUrl = client.RequestUrl + "?" + auth;
            HttpWebRequest  request    = (HttpWebRequest)WebRequest.Create(requestUrl);
            HttpWebResponse response   = (HttpWebResponse)request.GetResponse();
            string          content    = new StreamReader(response.GetResponseStream()).ReadToEnd();

            return(JsonConvert.DeserializeObject(content));
        }
Exemple #20
0
        /// <summary>
        /// Gets tokens for login.
        /// </summary>
        /// <returns></returns>
        public (string OAuthToken, string OAuthTokenSecret) GetOauthTokens()
        {
            if (string.IsNullOrEmpty(_auth.TokenSecret) || string.IsNullOrEmpty(_auth.VerifierSecret))
            {
                throw new Exception("Need to be logged in first.");
            }

            //Create access token request
            var client = new OAuthRequest
            {
                Method          = "GET",
                Type            = OAuthRequestType.RequestToken,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ConsumerKey     = _auth.ConsumerKey,
                ConsumerSecret  = _auth.ConsumerSecret,
                Token           = _auth.Token,
                TokenSecret     = _auth.TokenSecret,
                RequestUrl      = RequestAccessTokenUrl,
                Verifier        = _auth.VerifierSecret
            };

            //Build request url and send the request
            var url      = client.RequestUrl + "?" + client.GetAuthorizationQuery();
            var request  = (HttpWebRequest)WebRequest.Create(url);
            var response = (HttpWebResponse)request.GetResponse();

            using var dataStream = response.GetResponseStream();
            var reader             = new StreamReader(dataStream);
            var responseFromServer = reader.ReadToEnd();

            //Parse and save access token and secret
            var OAuthToken       = HttpUtility.ParseQueryString(responseFromServer).Get("oauth_token");
            var OAuthTokenSecret = HttpUtility.ParseQueryString(responseFromServer).Get("oauth_token_secret");

            return(OAuthToken, OAuthTokenSecret);
        }
Exemple #21
0
        /// <summary>
        ///     Gets the response from VATSIM SSO.
        /// </summary>
        /// <param name="oauthRequest">
        ///     The <see cref="OAuthRequest"/>.
        /// </param>
        /// <param name="raw">
        ///		The raw JSON response.
        /// </param>
        /// <returns>
        ///     The <see cref="IReponse"/>.
        /// </returns>
        private static T GetResponse <T>(OAuthRequest oauthRequest, out string raw)
        {
            // Check that the type is of IResponse
            if (!typeof(IReponse).IsAssignableFrom(typeof(T)))
            {
                throw new InvalidOperationException("The given type " + typeof(T).Name + " does not implement IResponse.");
            }

            // Pre-set the raw output
            raw = string.Empty;

            // Get the auth query
            string auth = oauthRequest.GetAuthorizationQuery();

            // Create the web request and add auth query to the url
            string         url     = oauthRequest.RequestUrl + '?' + auth;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            // Get the response
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            string          json     = string.Empty;

            using (StreamReader responseStream = new StreamReader(response.GetResponseStream())) json = responseStream.ReadToEnd();

            // Deserialize the JSON string into an IResponse and account for the date time formatting
            T data = JsonConvert.DeserializeObject <T>(json, new IsoDateTimeConverter {
                DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
            });

            if (data != null)
            {
                raw = json;
            }

            return(data);
        }
        public async Task <RequestTokenInfo> GetRequestToken()
        {
            OAuthRequest client = OAuthRequest.ForRequestToken(
                Resources.ConsumerKey,
                Resources.ConsumerSecret,
                Resources.CallbackURL);

            client.RequestUrl = Resources.RequestTokenURL;

            // Using URL query authorization
            var responseString = await Tools.GetStringResponse(string.Format("{0}?{1}", client.RequestUrl, client.GetAuthorizationQuery()));

            var tokenValues = GetTokenValues(responseString);

            var requestTokenInfo = new RequestTokenInfo();

            requestTokenInfo.RequestToken      = tokenValues[0];
            requestTokenInfo.RequestSecret     = tokenValues[1];
            requestTokenInfo.CallbackConfirmed = tokenValues[2];
            requestTokenInfo.CallbackUrl       = Resources.CallbackURL;

            requestTokenInfo.AccessUrl = string.Format("{0}?oauth_token={1}", Resources.AuthorizeURL, requestTokenInfo.RequestToken);

            return(requestTokenInfo);
        }