api_op_StartDeviceAuthorization.go raw

   1  // Code generated by smithy-go-codegen DO NOT EDIT.
   2  
   3  package ssooidc
   4  
   5  import (
   6  	"context"
   7  	"fmt"
   8  	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
   9  	"github.com/aws/smithy-go/middleware"
  10  	smithyhttp "github.com/aws/smithy-go/transport/http"
  11  )
  12  
  13  // Initiates device authorization by requesting a pair of verification codes from
  14  // the authorization service.
  15  func (c *Client) StartDeviceAuthorization(ctx context.Context, params *StartDeviceAuthorizationInput, optFns ...func(*Options)) (*StartDeviceAuthorizationOutput, error) {
  16  	if params == nil {
  17  		params = &StartDeviceAuthorizationInput{}
  18  	}
  19  
  20  	result, metadata, err := c.invokeOperation(ctx, "StartDeviceAuthorization", params, optFns, c.addOperationStartDeviceAuthorizationMiddlewares)
  21  	if err != nil {
  22  		return nil, err
  23  	}
  24  
  25  	out := result.(*StartDeviceAuthorizationOutput)
  26  	out.ResultMetadata = metadata
  27  	return out, nil
  28  }
  29  
  30  type StartDeviceAuthorizationInput struct {
  31  
  32  	// The unique identifier string for the client that is registered with IAM
  33  	// Identity Center. This value should come from the persisted result of the RegisterClientAPI
  34  	// operation.
  35  	//
  36  	// This member is required.
  37  	ClientId *string
  38  
  39  	// A secret string that is generated for the client. This value should come from
  40  	// the persisted result of the RegisterClientAPI operation.
  41  	//
  42  	// This member is required.
  43  	ClientSecret *string
  44  
  45  	// The URL for the Amazon Web Services access portal. For more information, see [Using the Amazon Web Services access portal]
  46  	// in the IAM Identity Center User Guide.
  47  	//
  48  	// [Using the Amazon Web Services access portal]: https://docs.aws.amazon.com/singlesignon/latest/userguide/using-the-portal.html
  49  	//
  50  	// This member is required.
  51  	StartUrl *string
  52  
  53  	noSmithyDocumentSerde
  54  }
  55  
  56  type StartDeviceAuthorizationOutput struct {
  57  
  58  	// The short-lived code that is used by the device when polling for a session
  59  	// token.
  60  	DeviceCode *string
  61  
  62  	// Indicates the number of seconds in which the verification code will become
  63  	// invalid.
  64  	ExpiresIn int32
  65  
  66  	// Indicates the number of seconds the client must wait between attempts when
  67  	// polling for a session.
  68  	Interval int32
  69  
  70  	// A one-time user verification code. This is needed to authorize an in-use device.
  71  	UserCode *string
  72  
  73  	// The URI of the verification page that takes the userCode to authorize the
  74  	// device.
  75  	VerificationUri *string
  76  
  77  	// An alternate URL that the client can use to automatically launch a browser.
  78  	// This process skips the manual step in which the user visits the verification
  79  	// page and enters their code.
  80  	VerificationUriComplete *string
  81  
  82  	// Metadata pertaining to the operation's result.
  83  	ResultMetadata middleware.Metadata
  84  
  85  	noSmithyDocumentSerde
  86  }
  87  
  88  func (c *Client) addOperationStartDeviceAuthorizationMiddlewares(stack *middleware.Stack, options Options) (err error) {
  89  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  90  		return err
  91  	}
  92  	err = stack.Serialize.Add(&awsRestjson1_serializeOpStartDeviceAuthorization{}, middleware.After)
  93  	if err != nil {
  94  		return err
  95  	}
  96  	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpStartDeviceAuthorization{}, middleware.After)
  97  	if err != nil {
  98  		return err
  99  	}
 100  	if err := addProtocolFinalizerMiddlewares(stack, options, "StartDeviceAuthorization"); err != nil {
 101  		return fmt.Errorf("add protocol finalizers: %v", err)
 102  	}
 103  
 104  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
 105  		return err
 106  	}
 107  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 108  		return err
 109  	}
 110  	if err = addClientRequestID(stack); err != nil {
 111  		return err
 112  	}
 113  	if err = addComputeContentLength(stack); err != nil {
 114  		return err
 115  	}
 116  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 117  		return err
 118  	}
 119  	if err = addRetry(stack, options); err != nil {
 120  		return err
 121  	}
 122  	if err = addRawResponseToMetadata(stack); err != nil {
 123  		return err
 124  	}
 125  	if err = addRecordResponseTiming(stack); err != nil {
 126  		return err
 127  	}
 128  	if err = addSpanRetryLoop(stack, options); err != nil {
 129  		return err
 130  	}
 131  	if err = addClientUserAgent(stack, options); err != nil {
 132  		return err
 133  	}
 134  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 135  		return err
 136  	}
 137  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 138  		return err
 139  	}
 140  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 141  		return err
 142  	}
 143  	if err = addTimeOffsetBuild(stack, c); err != nil {
 144  		return err
 145  	}
 146  	if err = addUserAgentRetryMode(stack, options); err != nil {
 147  		return err
 148  	}
 149  	if err = addCredentialSource(stack, options); err != nil {
 150  		return err
 151  	}
 152  	if err = addOpStartDeviceAuthorizationValidationMiddleware(stack); err != nil {
 153  		return err
 154  	}
 155  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartDeviceAuthorization(options.Region), middleware.Before); err != nil {
 156  		return err
 157  	}
 158  	if err = addRecursionDetection(stack); 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  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 171  		return err
 172  	}
 173  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 174  		return err
 175  	}
 176  	if err = addInterceptAttempt(stack, options); err != nil {
 177  		return err
 178  	}
 179  	if err = addInterceptors(stack, options); err != nil {
 180  		return err
 181  	}
 182  	return nil
 183  }
 184  
 185  func newServiceMetadataMiddleware_opStartDeviceAuthorization(region string) *awsmiddleware.RegisterServiceMetadata {
 186  	return &awsmiddleware.RegisterServiceMetadata{
 187  		Region:        region,
 188  		ServiceID:     ServiceID,
 189  		OperationName: "StartDeviceAuthorization",
 190  	}
 191  }
 192