internal HttpMessage CreateExchangeAadAccessTokenForAcrRefreshTokenRequest(PostContentSchemaGrantType grantType, string service, string tenant, string refreshToken, string accessToken)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Post;
            var uri = new RawRequestUriBuilder();

            uri.AppendRaw(_url, false);
            uri.AppendPath("/oauth2/exchange", false);
            uri.AppendQuery("api-version", _apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            var content = new FormUrlEncodedContent();

            content.Add("grant_type", grantType.ToString());
            content.Add("service", service);
            if (tenant != null)
            {
                content.Add("tenant", tenant);
            }
            if (refreshToken != null)
            {
                content.Add("refresh_token", refreshToken);
            }
            if (accessToken != null)
            {
                content.Add("access_token", accessToken);
            }
            request.Content = content;
            return(message);
        }
Esempio n. 2
0
        internal HttpMessage CreateExchangeAadAccessTokenForAcrRefreshTokenRequest(string service, string accessToken)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Post;
            var uri = new RawRequestUriBuilder();

            uri.AppendRaw(url, false);
            uri.AppendPath("/oauth2/exchange", false);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            var content = new FormUrlEncodedContent();

            content.Add("grant_type", "access_token");
            content.Add("service", service);
            content.Add("access_token", accessToken);
            request.Content = content;
            return(message);
        }
        internal HttpMessage CreatePostRequest(string version, PostContentSchemaGrantType grantType, Enum422?acceptLanguage, string clientId, string clientSecret, string scope, string refreshToken, string username, string password, string token, int?company, int?user, string key)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Post;
            var uri = new RawRequestUriBuilder();

            uri.Reset(endpoint);
            uri.AppendPath("/api/v", false);
            uri.AppendPath(version, true);
            uri.AppendPath("/oauth/token", false);
            request.Uri = uri;
            if (acceptLanguage != null)
            {
                request.Headers.Add("Accept-Language", acceptLanguage.Value.ToString());
            }
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            var content = new FormUrlEncodedContent();

            content.Add("grant_type", grantType.ToString());
            if (clientId != null)
            {
                content.Add("client_id", clientId);
            }
            if (clientSecret != null)
            {
                content.Add("client_secret", clientSecret);
            }
            if (scope != null)
            {
                content.Add("scope", scope);
            }
            if (refreshToken != null)
            {
                content.Add("refresh_token", refreshToken);
            }
            if (username != null)
            {
                content.Add("username", username);
            }
            if (password != null)
            {
                content.Add("password", password);
            }
            if (token != null)
            {
                content.Add("token", token);
            }
            if (company != null)
            {
                content.Add("company", company.Value.ToString());
            }
            if (user != null)
            {
                content.Add("user", user.Value.ToString());
            }
            if (key != null)
            {
                content.Add("key", key);
            }
            request.Content = content;
            return(message);
        }