api_op_CreateOAuth2TokenWithIAM.go (3326B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package signin 4 5 import ( 6 "context" 7 8 "github.com/aws/smithy-go/middleware" 9 "github.com/aws/smithy-go/ptr" 10 ) 11 12 // Grants permission to exchange client credentials for an OAuth 2.0 access token 13 // scoped to a resource that can be used to access AWS services from applications 14 func (c *Client) CreateOAuth2TokenWithIAM(ctx context.Context, params *CreateOAuth2TokenWithIAMInput, optFns ...func(*Options)) (*CreateOAuth2TokenWithIAMOutput, error) { 15 if params == nil { 16 params = &CreateOAuth2TokenWithIAMInput{} 17 } 18 19 result, metadata, err := c.invokeOperation(ctx, "CreateOAuth2TokenWithIAM", params, optFns, c.addOperationCreateOAuth2TokenWithIAMMiddlewares) 20 if err != nil { 21 return nil, err 22 } 23 24 out := result.(*CreateOAuth2TokenWithIAMOutput) 25 out.ResultMetadata = metadata 26 return out, nil 27 } 28 29 // Input structure for CreateOAuth2TokenWithIAM operation 30 type CreateOAuth2TokenWithIAMInput struct { 31 32 // OAuth 2.0 grant type. Must be "client_credentials". 33 // 34 // This member is required. 35 GrantType *string 36 37 // The OAuth resource for which the access token is requested. Example: 38 // "aws-mcp.amazonaws.com". 39 // 40 // This member is required. 41 Resource *string 42 43 noSmithyDocumentSerde 44 } 45 46 func (in *CreateOAuth2TokenWithIAMInput) bindEndpointParams(p *EndpointParameters) { 47 48 p.IsOAuthEndpoint = ptr.Bool(true) 49 } 50 51 // Output structure for CreateOAuth2TokenWithIAM operation 52 // 53 // Contains the JWT access token, token type, and expiration per RFC 6749 ยง5.1. 54 type CreateOAuth2TokenWithIAMOutput struct { 55 56 // JWT access token containing principal identity, resource scope, and session 57 // metadata 58 // 59 // This member is required. 60 AccessToken *string 61 62 // Token lifetime in seconds. Value is the minimum of session validity and 1 hour. 63 // 64 // This member is required. 65 ExpiresIn *int32 66 67 // Always "Bearer" per OAuth 2.1 specification 68 // 69 // This member is required. 70 TokenType *string 71 72 // Metadata pertaining to the operation's result. 73 ResultMetadata middleware.Metadata 74 75 noSmithyDocumentSerde 76 } 77 78 func (c *Client) addOperationCreateOAuth2TokenWithIAMMiddlewares(stack *middleware.Stack, options Options) (err error) { 79 err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateOAuth2TokenWithIAM{}, middleware.After) 80 if err != nil { 81 return err 82 } 83 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateOAuth2TokenWithIAM{}, middleware.After) 84 if err != nil { 85 return err 86 } 87 88 if err = addComputeContentLength(stack); err != nil { 89 return err 90 } 91 if err = addResolveEndpointMiddleware(stack, options); err != nil { 92 return err 93 } 94 if err = addComputePayloadSHA256(stack); err != nil { 95 return err 96 } 97 if err = addRecordResponseTiming(stack, options); err != nil { 98 return err 99 } 100 if err = addCredentialSource(stack, options); err != nil { 101 return err 102 } 103 if err = addOpCreateOAuth2TokenWithIAMValidationMiddleware(stack); err != nil { 104 return err 105 } 106 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 107 return err 108 } 109 if err = addResponseErrorMiddleware(stack); err != nil { 110 return err 111 } 112 if err = addRequestResponseLogging(stack, options); err != nil { 113 return err 114 } 115 if err = addDisableHTTPSMiddleware(stack, options); err != nil { 116 return err 117 } 118 if err = addInterceptors(stack, options); err != nil { 119 return err 120 } 121 return nil 122 }