public OAuth.Token CompleteAuthentication(string verifier, OAuth.Token requestToken) { string response = SignedPost("http://api.rdio.com/oauth/access_token", new Dictionary <string, string> { { "oauth_verifier", verifier } }, requestToken); NameValueCollection parsed = HttpUtility.ParseQueryString(response); return(new OAuth.Token(parsed["oauth_token"], parsed["oauth_token_secret"])); }
public AuthState BeginAuthentication(string callback) { string response = SignedPost("http://api.rdio.com/oauth/request_token", new Dictionary <string, string> { { "oauth_callback", callback } }, null); NameValueCollection parsed = HttpUtility.ParseQueryString(response); OAuth.Token requestToken = new OAuth.Token(parsed["oauth_token"], parsed["oauth_token_secret"]); string url = parsed["login_url"] + "?oauth_token=" + requestToken.Token_; return(new AuthState(requestToken, url)); }
protected string SignedPost(string url, IDictionary <string, string> parameters, OAuth.Token token) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.Headers.Add("Authorization", OAuth.Sign(Consumer, url, parameters, token, "POST", null)); StreamWriter streamWriter = new StreamWriter(request.GetRequestStream()); streamWriter.Write(OAuth.PercentEscape(parameters)); streamWriter.Close(); HttpWebResponse response; try { response = (HttpWebResponse)request.GetResponse(); } catch (WebException e) { RdioException re; response = (HttpWebResponse)e.Response; if (response.StatusCode == HttpStatusCode.Forbidden || response.StatusCode == HttpStatusCode.Unauthorized) { re = new AuthorizationException(); } else { re = new RdioException(); } re.Request = request; re.Response = response; re.Exception = e; throw re; } StreamReader streamReader = new StreamReader(response.GetResponseStream()); return(streamReader.ReadToEnd()); }
public RdioClient(OAuth.Consumer consumer, OAuth.Token accessToken) { Consumer = consumer; AccessToken = accessToken; }
public AuthState(OAuth.Token requestToken, string url) { RequestToken = requestToken; Url = url; }
public RdioClient (OAuth.Consumer consumer, OAuth.Token accessToken) { Consumer = consumer; AccessToken = accessToken; }
public AuthState BeginAuthentication(string callback) { string response = SignedPost("http://api.rdio.com/oauth/request_token", new Dictionary<string,string> { { "oauth_callback", callback } }, null); NameValueCollection parsed = HttpUtility.ParseQueryString(response); OAuth.Token requestToken = new OAuth.Token(parsed["oauth_token"], parsed["oauth_token_secret"]); string url = parsed["login_url"] + "?oauth_token=" + requestToken.Token_; return new AuthState(requestToken, url); }