api_op_CreateToken.go 6.1 KB

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