api_op_CreateToken.go (5870B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package ssooidc 4 5 import ( 6 "context" 7 8 "github.com/aws/smithy-go/middleware" 9 ) 10 11 // Creates and returns access and refresh tokens for clients that are 12 // authenticated using client secrets. The access token can be used to fetch 13 // short-lived credentials for the assigned AWS accounts or to access application 14 // APIs using bearer authentication. 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 the client or application. This value comes 33 // from the result of the RegisterClientAPI. 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 RegisterClientAPI. 40 // 41 // This member is required. 42 ClientSecret *string 43 44 // Supports the following OAuth grant types: Authorization Code, Device Code, and 45 // Refresh Token. Specify one of the following values, depending on the grant type 46 // that you want: 47 // 48 // * Authorization Code - authorization_code 49 // 50 // * Device Code - urn:ietf:params:oauth:grant-type:device_code 51 // 52 // * Refresh Token - refresh_token 53 // 54 // This member is required. 55 GrantType *string 56 57 // Used only when calling this API for the Authorization Code grant type. The 58 // short-lived code is used to identify this authorization request. 59 Code *string 60 61 // Used only when calling this API for the Authorization Code grant type. This 62 // value is generated by the client and presented to validate the original code 63 // challenge value the client passed at authorization time. 64 CodeVerifier *string 65 66 // Used only when calling this API for the Device Code grant type. This 67 // short-lived code is used to identify this authorization request. This comes from 68 // the result of the StartDeviceAuthorizationAPI. 69 DeviceCode *string 70 71 // Used only when calling this API for the Authorization Code grant type. This 72 // value specifies the location of the client or application that has registered to 73 // receive the authorization code. 74 RedirectUri *string 75 76 // Used only when calling this API for the Refresh Token grant type. This token is 77 // used to refresh short-lived tokens, such as the access token, that might expire. 78 // 79 // For more information about the features and limitations of the current IAM 80 // Identity Center OIDC implementation, see Considerations for Using this Guide in 81 // the [IAM Identity Center OIDC API Reference]. 82 // 83 // [IAM Identity Center OIDC API Reference]: https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html 84 RefreshToken *string 85 86 // The list of scopes for which authorization is requested. This parameter has no 87 // effect; the access token will always include all scopes configured during client 88 // registration. 89 Scope []string 90 91 noSmithyDocumentSerde 92 } 93 94 type CreateTokenOutput struct { 95 96 // A bearer token to access Amazon Web Services accounts and applications assigned 97 // to a user. 98 AccessToken *string 99 100 // Indicates the time in seconds when an access token will expire. 101 ExpiresIn int32 102 103 // The idToken is not implemented or supported. For more information about the 104 // features and limitations of the current IAM Identity Center OIDC implementation, 105 // see Considerations for Using this Guide in the [IAM Identity Center OIDC API Reference]. 106 // 107 // A JSON Web Token (JWT) that identifies who is associated with the issued access 108 // token. 109 // 110 // [IAM Identity Center OIDC API Reference]: https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html 111 IdToken *string 112 113 // A token that, if present, can be used to refresh a previously issued access 114 // token that might have expired. 115 // 116 // For more information about the features and limitations of the current IAM 117 // Identity Center OIDC implementation, see Considerations for Using this Guide in 118 // the [IAM Identity Center OIDC API Reference]. 119 // 120 // [IAM Identity Center OIDC API Reference]: https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/Welcome.html 121 RefreshToken *string 122 123 // Used to notify the client that the returned token is an access token. The 124 // supported token type is Bearer . 125 TokenType *string 126 127 // Metadata pertaining to the operation's result. 128 ResultMetadata middleware.Metadata 129 130 noSmithyDocumentSerde 131 } 132 133 func (c *Client) addOperationCreateTokenMiddlewares(stack *middleware.Stack, options Options) (err error) { 134 err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateToken{}, middleware.After) 135 if err != nil { 136 return err 137 } 138 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateToken{}, middleware.After) 139 if err != nil { 140 return err 141 } 142 143 if err = addComputeContentLength(stack); err != nil { 144 return err 145 } 146 if err = addResolveEndpointMiddleware(stack, options); err != nil { 147 return err 148 } 149 if err = addRecordResponseTiming(stack, options); err != nil { 150 return err 151 } 152 if err = addCredentialSource(stack, options); err != nil { 153 return err 154 } 155 if err = addOpCreateTokenValidationMiddleware(stack); err != nil { 156 return err 157 } 158 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 159 return err 160 } 161 if err = addResponseErrorMiddleware(stack); err != nil { 162 return err 163 } 164 if err = addRequestResponseLogging(stack, options); err != nil { 165 return err 166 } 167 if err = addDisableHTTPSMiddleware(stack, options); err != nil { 168 return err 169 } 170 if err = addInterceptors(stack, options); err != nil { 171 return err 172 } 173 return nil 174 }