api_op_CreateToken.go (6260B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package ssooidc 4 5 import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/smithy-go/middleware" 9 smithyhttp "github.com/aws/smithy-go/transport/http" 10 ) 11 12 // Creates and returns an access token for the authorized client. The access token 13 // issued will be used to fetch short-term credentials for the assigned roles in 14 // the AWS account. 15 func (c *Client) CreateToken(ctx context.Context, params *CreateTokenInput, optFns ...func(*Options)) (*CreateTokenOutput, error) { 16 if params == nil { 17 params = &CreateTokenInput{} 18 } 19 20 result, metadata, err := c.invokeOperation(ctx, "CreateToken", params, optFns, c.addOperationCreateTokenMiddlewares) 21 if err != nil { 22 return nil, err 23 } 24 25 out := result.(*CreateTokenOutput) 26 out.ResultMetadata = metadata 27 return out, nil 28 } 29 30 type CreateTokenInput struct { 31 32 // The unique identifier string for each client. This value should come from the 33 // persisted result of the RegisterClient API. 34 // 35 // This member is required. 36 ClientId *string 37 38 // A secret string generated for the client. This value should come from the 39 // persisted result of the RegisterClient API. 40 // 41 // This member is required. 42 ClientSecret *string 43 44 // Supports grant types for the authorization code, refresh token, and device code 45 // request. For device code requests, specify the following value: 46 // urn:ietf:params:oauth:grant-type:device_code For information about how to 47 // obtain the device code, see the StartDeviceAuthorization topic. 48 // 49 // This member is required. 50 GrantType *string 51 52 // The authorization code received from the authorization service. This parameter 53 // is required to perform an authorization grant request to get access to a token. 54 Code *string 55 56 // Used only when calling this API for the device code grant type. This short-term 57 // code is used to identify this authentication attempt. This should come from an 58 // in-memory reference to the result of the StartDeviceAuthorization API. 59 DeviceCode *string 60 61 // The location of the application that will receive the authorization code. Users 62 // authorize the service to send the request to this location. 63 RedirectUri *string 64 65 // Currently, refreshToken is not yet implemented and is not supported. For more 66 // information about the features and limitations of the current IAM Identity 67 // Center OIDC implementation, see Considerations for Using this Guide in the IAM 68 // Identity Center OIDC API Reference 69 // (https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html). 70 // The token used to obtain an access token in the event that the access token is 71 // invalid or expired. 72 RefreshToken *string 73 74 // The list of scopes that is defined by the client. Upon authorization, this list 75 // is used to restrict permissions when granting an access token. 76 Scope []string 77 78 noSmithyDocumentSerde 79 } 80 81 type CreateTokenOutput struct { 82 83 // An opaque token to access IAM Identity Center resources assigned to a user. 84 AccessToken *string 85 86 // Indicates the time in seconds when an access token will expire. 87 ExpiresIn int32 88 89 // Currently, idToken is not yet implemented and is not supported. For more 90 // information about the features and limitations of the current IAM Identity 91 // Center OIDC implementation, see Considerations for Using this Guide in the IAM 92 // Identity Center OIDC API Reference 93 // (https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html). 94 // The identifier of the user that associated with the access token, if present. 95 IdToken *string 96 97 // Currently, refreshToken is not yet implemented and is not supported. For more 98 // information about the features and limitations of the current IAM Identity 99 // Center OIDC implementation, see Considerations for Using this Guide in the IAM 100 // Identity Center OIDC API Reference 101 // (https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html). 102 // A token that, if present, can be used to refresh a previously issued access 103 // token that might have expired. 104 RefreshToken *string 105 106 // Used to notify the client that the returned token is an access token. The 107 // supported type is BearerToken. 108 TokenType *string 109 110 // Metadata pertaining to the operation's result. 111 ResultMetadata middleware.Metadata 112 113 noSmithyDocumentSerde 114 } 115 116 func (c *Client) addOperationCreateTokenMiddlewares(stack *middleware.Stack, options Options) (err error) { 117 err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateToken{}, middleware.After) 118 if err != nil { 119 return err 120 } 121 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateToken{}, middleware.After) 122 if err != nil { 123 return err 124 } 125 if err = addSetLoggerMiddleware(stack, options); err != nil { 126 return err 127 } 128 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 129 return err 130 } 131 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 132 return err 133 } 134 if err = addResolveEndpointMiddleware(stack, options); err != nil { 135 return err 136 } 137 if err = addRetryMiddlewares(stack, options); err != nil { 138 return err 139 } 140 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 141 return err 142 } 143 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 144 return err 145 } 146 if err = addClientUserAgent(stack); err != nil { 147 return err 148 } 149 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 150 return err 151 } 152 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 153 return err 154 } 155 if err = addOpCreateTokenValidationMiddleware(stack); err != nil { 156 return err 157 } 158 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateToken(options.Region), middleware.Before); err != nil { 159 return err 160 } 161 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 162 return err 163 } 164 if err = addResponseErrorMiddleware(stack); err != nil { 165 return err 166 } 167 if err = addRequestResponseLogging(stack, options); err != nil { 168 return err 169 } 170 return nil 171 } 172 173 func newServiceMetadataMiddleware_opCreateToken(region string) *awsmiddleware.RegisterServiceMetadata { 174 return &awsmiddleware.RegisterServiceMetadata{ 175 Region: region, 176 ServiceID: ServiceID, 177 OperationName: "CreateToken", 178 } 179 }