Ejemplo n.º 1
0
        public Task <AccessTokenResponse> GetAccessToken(string code, string redirectUrl = "urn:ietf:wg:oauth:2.0:oob")
        {
            var url = new Uri(this._oauthBaseUrl, "token");

            var parameters = new Query
            {
                ["client_id"]     = this.Api.ClientId,
                ["client_secret"] = this.Api.ClientSecret,
                ["grant_type"]    = "authorization_code",
                ["redirect_uri"]  = redirectUrl,
                ["code"]          = code,
            };

            return(this.Api.SendRequest <AccessTokenResponse>(WebUtility.CreateWebRequest(HttpMethod.Post, url, parameters)));
        }
Ejemplo n.º 2
0
            public Task <ClientKeyInfo> Register(Uri hostUrl, string clientName, string[] scopes, string redirectUris = "urn:ietf:wg:oauth:2.0:oob", Uri website = null)
            {
                var query = new Query
                {
                    ["client_name"]   = clientName,
                    ["redirect_uris"] = redirectUris,
                    ["scopes"]        = string.Join(" ", scopes),
                };

                if (website != null)
                {
                    query["website"] = website.AbsoluteUri;
                }

                var url = new Uri(hostUrl + "/api/v1/apps");

                var request = WebUtility.CreateWebRequest(HttpMethod.Post, url, query);

                return(this.Api.SendRequest <ClientKeyInfo>(request));
            }
Ejemplo n.º 3
0
 internal HttpRequestMessage CreateApiRequest(HttpMethod method, Uri endpoint, IQuery query = null)
 {
     return(WebUtility.CreateWebRequest(method, endpoint, query, this._authorizeHeader));
 }