public IRequest Authorize(string clientId, string callbackUrl, IEnumerable<Scope> requestedScopes, string state = null)
        {
            var request = new Request
            {
                BaseAddress = OAuthUrlBase,
                Resource = OAuthResource.Replace("{verb}", AuthorizeVerb),
                Method = HttpMethod.Get
            };
            request.AddParameter("client_id", clientId);
            request.AddParameter("scope", string.Join(" ", requestedScopes.OrderBy(s => s).Select(s => s.GetDescription())));
            request.AddParameter("response_type", "code");
            request.AddParameter("redirect_uri", callbackUrl);

            if (!string.IsNullOrEmpty(state))
                request.AddParameter("state", state);

            return request;
        }
Ejemplo n.º 2
0
        public IRequest GetAccessToken(string clientId, string clientSecret, string callbackUrl, string authorizationCode)
        {
            var nvc = new Dictionary<string, string>();
            nvc["client_id"] = clientId;
            nvc["redirect_uri"] = callbackUrl;
            nvc["client_secret"] = clientSecret;
            nvc["code"] = authorizationCode;
            nvc["grant_type"] = "authorization_code";

            var request = new Request
            {
                BaseAddress = OAuthUrlBase,
                Resource = OAuthResource.Replace("{verb}", TokenVerb),
                Method = HttpMethod.Post,
                Content = new FormUrlEncodedContent(nvc)
            };

            return request;
        }
Ejemplo n.º 3
0
 private Request ContentRequest(HttpMethod method, string baseUrl, string resource)
 {
     var request = new Request
     {
         BaseAddress = baseUrl,
         Resource = Append(resource),
         Method = method
     };
     return request;
 }