public Task <Response <AcrRefreshToken> > ExchangeAadAccessTokenForAcrRefreshTokenAsync(PostContentSchemaGrantType grantType, string service, string tenant = null, string refreshToken = null, string accessToken = null, CancellationToken cancellationToken = default) { return(Task.FromResult(Response.FromValue(_acrRefreshTokenFunc(service), new MockResponse(200)))); }
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); }
internal Paths1Il3PoeApiVVersionOauthTokenPostRequestbodyContentApplicationXWwwFormUrlencodedSchema(PostContentSchemaGrantType grantType) { GrantType = grantType; }
public async Task <Response <AuthenticationResponse> > PostAsync(string version, PostContentSchemaGrantType grantType, Enum422?acceptLanguage = null, string clientId = null, string clientSecret = null, string scope = null, string refreshToken = null, string username = null, string password = null, string token = null, int?company = null, int?user = null, string key = null, CancellationToken cancellationToken = default) { if (version == null) { throw new ArgumentNullException(nameof(version)); } using var message = CreatePostRequest(version, grantType, acceptLanguage, clientId, clientSecret, scope, refreshToken, username, password, token, company, user, key); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { AuthenticationResponse value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = AuthenticationResponse.DeserializeAuthenticationResponse(document.RootElement); return(Response.FromValue(value, message.Response)); }