Exemple #1
0
        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"]));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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());
        }
Exemple #4
0
 public RdioClient(OAuth.Consumer consumer, OAuth.Token accessToken)
 {
     Consumer    = consumer;
     AccessToken = accessToken;
 }
Exemple #5
0
 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(OAuth.Token requestToken, string url) {
				RequestToken = requestToken;
				Url = url;
			}
		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);
		}