public override Task <Uri> GetInitialUrlAsync() { var req = OAuth1.CreateRequest( "GET", requestTokenUrl, new Dictionary <string, string> (), consumerKey, consumerSecret, "" ); return(req.GetResponseAsync().ContinueWith(respTask => { var content = respTask.Result.GetResponseText(); var r = WebEx.FormDecode(content); token = r["oauth_token"]; tokenSecret = r["oauth_token_secret"]; string paramType = authorizeUrl.AbsoluteUri.IndexOf("?") >= 0 ? "&" : "?"; var url = String.Format("{0}{1}oauth_token={2}&oauth_callback={3}", authorizeUrl.AbsoluteUri, paramType, Uri.EscapeDataString(token), Uri.EscapeDataString(callbackUrl.AbsoluteUri)); return new Uri(url); })); }
/// <summary> /// Method that returns the initial URL to be displayed in the web browser. /// </summary> /// <returns> /// A task that will return the initial URL. /// </returns> public override Task <Uri> GetInitialUrlAsync() { var req = OAuth1.CreateRequest( "GET", requestTokenUrl, new Dictionary <string, string>() { { "oauth_callback", callbackUrl.AbsoluteUri }, }, consumerKey, consumerSecret, ""); return(req.GetResponseAsync().ContinueWith(respTask => { var content = respTask.Result.GetResponseText(); var r = WebEx.FormDecode(content); token = r["oauth_token"]; tokenSecret = r["oauth_token_secret"]; var url = authorizeUrl.AbsoluteUri + "?oauth_token=" + Uri.EscapeDataString(token); return new Uri(url); })); }
/// <summary> /// Method that returns the initial URL to be displayed in the web browser. /// </summary> /// <returns> /// A task that will return the initial URL. /// </returns> public override Task <Uri> GetInitialUrlAsync() { /* * mc++ * OriginalString property of the Uri object should be used instead of AbsoluteUri * otherwise trailing slash is added. */ string oauth_callback_uri_absolute = callbackUrl.AbsoluteUri; string oauth_callback_uri_original = callbackUrl.OriginalString; System.Diagnostics.Debug.WriteLine("GetInitialUrlAsync callbackUrl.AbsoluteUri = " + oauth_callback_uri_absolute); System.Diagnostics.Debug.WriteLine("GetInitialUrlAsync callbackUrl.OriginalString = " + oauth_callback_uri_original); string oauth_callback_uri = oauth_callback_uri_absolute; var req = OAuth1.CreateRequest ( "GET", requestTokenUrl, new Dictionary <string, string>() { { "oauth_callback", oauth_callback_uri }, }, consumerKey, consumerSecret, "" ); if (this.HttpWebClientFrameworkType == HttpWebClientFrameworkType.WebRequest) { return(req.GetResponseAsync() .ContinueWith ( respTask => { var content = respTask.Result.GetResponseText(); var r = WebEx.FormDecode(content); token = r["oauth_token"]; tokenSecret = r["oauth_token_secret"]; string paramType = authorizeUrl.AbsoluteUri.IndexOf("?") >= 0 ? "&" : "?"; var url = authorizeUrl.AbsoluteUri + paramType + "oauth_token=" + Uri.EscapeDataString(token); return new Uri(url); } )); } else if (this.HttpWebClientFrameworkType == HttpWebClientFrameworkType.HttpClient) { throw new NotImplementedException("HttpClient implementation!"); } return(null); }
Task GetAccessTokenAsync() { var requestParams = new Dictionary <string, string> { { "oauth_token", token } }; if (verifier != null) { requestParams["oauth_verifier"] = verifier; } var req = OAuth1.CreateRequest( "GET", accessTokenUrl, requestParams, consumerKey, consumerSecret, tokenSecret); if (this.HttpWebClientFrameworkType == HttpWebClientFrameworkType.WebRequest) { return(req.GetResponseAsync().ContinueWith(respTask => { var content = respTask.Result.GetResponseText(); var accountProperties = WebEx.FormDecode(content); accountProperties["oauth_consumer_key"] = consumerKey; accountProperties["oauth_consumer_secret"] = consumerSecret; if (getUsernameAsync != null) { getUsernameAsync(accountProperties).ContinueWith(uTask => { if (uTask.IsFaulted) { OnError(uTask.Exception); } else { OnSucceeded(uTask.Result, accountProperties); } }); } else { OnSucceeded("", accountProperties); } })); } else if (this.HttpWebClientFrameworkType == HttpWebClientFrameworkType.HttpClient) { throw new NotImplementedException("HttpClient implementation!"); } return(null); }
Task GetAccessTokenAsync() { var requestparams = new Dictionary <string, string> { { "oauth_token", token }, }; if (verifier != null) { requestparams["oauth_verifier"] = verifier; } var req = OAuth1.CreateRequest( "GET", accessTokenUrl, requestparams, consumerKey, consumerSecret, tokenSecret); return(req.GetResponseAsync().ContinueWith(respTask => { var content = respTask.Result.GetResponseText(); var accountProperties = WebEx.FormDecode(content); accountProperties["oauth_consumer_key"] = consumerKey; accountProperties["oauth_consumer_secret"] = consumerSecret; if (getUsernameAsync != null) { getUsernameAsync(accountProperties).ContinueWith(uTask => { if (uTask.IsFaulted) { OnError(uTask.Exception); } else { OnSucceeded(uTask.Result, accountProperties); } }); } else { OnSucceeded("", accountProperties); } })); }
/// <summary> /// Method that returns the initial URL to be displayed in the web browser. /// </summary> /// <returns> /// A task that will return the initial URL. /// </returns> public override Task <Uri> GetInitialUrlAsync() { var req = OAuth1.CreateRequest( "GET", requestTokenUrl, new Dictionary <string, string>() { { "oauth_callback", callbackUrl.AbsoluteUri }, }, consumerKey, consumerSecret, ""); if (this.HttpWebClientFrameworkType == HttpWebClientFrameworkType.WebRequest) { return(req.GetResponseAsync().ContinueWith(respTask => { var content = respTask.Result.GetResponseText(); var r = WebEx.FormDecode(content); token = r["oauth_token"]; tokenSecret = r["oauth_token_secret"]; string paramType = authorizeUrl.AbsoluteUri.IndexOf("?") >= 0 ? "&" : "?"; var url = authorizeUrl.AbsoluteUri + paramType + "oauth_token=" + Uri.EscapeDataString(token); return new Uri(url); })); } else if (this.HttpWebClientFrameworkType == HttpWebClientFrameworkType.HttpClient) { throw new NotImplementedException("HttpClient implementation!"); } return(null); }
Task GetAccessTokenAsync() { #if DEBUG StringBuilder sb = new StringBuilder(); sb.AppendLine($"OAuth1Authenticator.GetAccessTokenAsync "); sb.AppendLine($" token = {token}"); System.Diagnostics.Debug.WriteLine(sb.ToString()); #endif var requestParams = new Dictionary <string, string> { { "oauth_token", token } }; if (verifier != null) { requestParams["oauth_verifier"] = verifier; System.Diagnostics.Debug.WriteLine($" verifier = {verifier}"); } var req = OAuth1.CreateRequest( "GET", accessTokenUrl, requestParams, consumerKey, consumerSecret, tokenSecret); if (this.HttpWebClientFrameworkType == HttpWebClientFrameworkType.WebRequest) { return(req.GetResponseAsync().ContinueWith(respTask => { var content = respTask.Result.GetResponseText(); var accountProperties = WebEx.FormDecode(content); accountProperties["oauth_consumer_key"] = consumerKey; accountProperties["oauth_consumer_secret"] = consumerSecret; if (getUsernameAsync != null) { getUsernameAsync(accountProperties).ContinueWith(uTask => { if (uTask.IsFaulted) { OnError(uTask.Exception); } else { OnSucceeded(uTask.Result, accountProperties); } }); } else { OnSucceeded("", accountProperties); } })); } else if (this.HttpWebClientFrameworkType == HttpWebClientFrameworkType.HttpClient) { throw new NotImplementedException("HttpClient implementation!"); } return(null); }
/// <summary> /// Method that returns the initial URL to be displayed in the web browser. /// </summary> /// <returns> /// A task that will return the initial URL. /// </returns> public override Task <Uri> GetInitialUrlAsync(Dictionary <string, string> query_parameters = null) { /* * mc++ * OriginalString property of the Uri object should be used instead of AbsoluteUri * * otherwise trailing slash is added. * * string[] uris = new string[] * { * "http://xamarin.com/", * "http://xamarin.com", * }; * foreach (string u in uris) * { * uri = new Uri(u); * Console.WriteLine("uri.AbsoluteUri = " + uri.AbsoluteUri); * Console.WriteLine("uri.OriginalString = " + uri.OriginalString); * } * * The problem is whether to send original string to be compared with registered * redirect_url on the authorization server od "correct" url (AblsoluteUrl) with * slash */ string oauth_callback_uri_absolute = callbackUrl.AbsoluteUri; string oauth_callback_uri_original = callbackUrl.OriginalString; System.Diagnostics.Debug.WriteLine("GetInitialUrlAsync callbackUrl.AbsoluteUri = " + oauth_callback_uri_absolute); System.Diagnostics.Debug.WriteLine("GetInitialUrlAsync callbackUrl.OriginalString = " + oauth_callback_uri_original); string oauth_callback_uri = oauth_callback_uri_absolute; var req = OAuth1.CreateRequest ( "GET", requestTokenUrl, new Dictionary <string, string>() { { "oauth_callback", oauth_callback_uri }, }, consumerKey, consumerSecret, "" ); if (this.HttpWebClientFrameworkType == HttpWebClientFrameworkType.WebRequest) { return(req.GetResponseAsync() .ContinueWith ( respTask => { var content = respTask.Result.GetResponseText(); var r = WebEx.FormDecode(content); token = r["oauth_token"]; tokenSecret = r["oauth_token_secret"]; string paramType = authorizeUrl.AbsoluteUri.IndexOf("?") >= 0 ? "&" : "?"; var url = authorizeUrl.AbsoluteUri + paramType + "oauth_token=" + Uri.EscapeDataString(token); return new Uri(url); } )); } else if (this.HttpWebClientFrameworkType == HttpWebClientFrameworkType.HttpClient) { throw new NotImplementedException("HttpClient implementation!"); } return(null); }