private Amazon.SSOOIDC.Model.CreateTokenResponse CallAWSServiceOperation(IAmazonSSOOIDC client, Amazon.SSOOIDC.Model.CreateTokenRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Single Sign-On OIDC", "CreateToken"); try { #if DESKTOP return(client.CreateToken(request)); #elif CORECLR return(client.CreateTokenAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.SSOOIDC.Model.CreateTokenRequest(); if (cmdletContext.ClientId != null) { request.ClientId = cmdletContext.ClientId; } if (cmdletContext.ClientSecret != null) { request.ClientSecret = cmdletContext.ClientSecret; } if (cmdletContext.Code != null) { request.Code = cmdletContext.Code; } if (cmdletContext.DeviceCode != null) { request.DeviceCode = cmdletContext.DeviceCode; } if (cmdletContext.GrantType != null) { request.GrantType = cmdletContext.GrantType; } if (cmdletContext.RedirectUri != null) { request.RedirectUri = cmdletContext.RedirectUri; } if (cmdletContext.RefreshToken != null) { request.RefreshToken = cmdletContext.RefreshToken; } if (cmdletContext.Scope != null) { request.Scope = cmdletContext.Scope; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return(output); }