src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

api_op_StartDeviceAuthorization.go (5178B)


      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
     34 	// RegisterClient API 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 RegisterClient API 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
     46 	// Using the Amazon Web Services access portal (https://docs.aws.amazon.com/singlesignon/latest/userguide/using-the-portal.html)
     47 	// in the IAM Identity Center User Guide.
     48 	//
     49 	// This member is required.
     50 	StartUrl *string
     51 
     52 	noSmithyDocumentSerde
     53 }
     54 
     55 type StartDeviceAuthorizationOutput struct {
     56 
     57 	// The short-lived code that is used by the device when polling for a session
     58 	// token.
     59 	DeviceCode *string
     60 
     61 	// Indicates the number of seconds in which the verification code will become
     62 	// invalid.
     63 	ExpiresIn int32
     64 
     65 	// Indicates the number of seconds the client must wait between attempts when
     66 	// polling for a session.
     67 	Interval int32
     68 
     69 	// A one-time user verification code. This is needed to authorize an in-use device.
     70 	UserCode *string
     71 
     72 	// The URI of the verification page that takes the userCode to authorize the
     73 	// device.
     74 	VerificationUri *string
     75 
     76 	// An alternate URL that the client can use to automatically launch a browser.
     77 	// This process skips the manual step in which the user visits the verification
     78 	// page and enters their code.
     79 	VerificationUriComplete *string
     80 
     81 	// Metadata pertaining to the operation's result.
     82 	ResultMetadata middleware.Metadata
     83 
     84 	noSmithyDocumentSerde
     85 }
     86 
     87 func (c *Client) addOperationStartDeviceAuthorizationMiddlewares(stack *middleware.Stack, options Options) (err error) {
     88 	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
     89 		return err
     90 	}
     91 	err = stack.Serialize.Add(&awsRestjson1_serializeOpStartDeviceAuthorization{}, middleware.After)
     92 	if err != nil {
     93 		return err
     94 	}
     95 	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpStartDeviceAuthorization{}, middleware.After)
     96 	if err != nil {
     97 		return err
     98 	}
     99 	if err := addProtocolFinalizerMiddlewares(stack, options, "StartDeviceAuthorization"); err != nil {
    100 		return fmt.Errorf("add protocol finalizers: %v", err)
    101 	}
    102 
    103 	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
    104 		return err
    105 	}
    106 	if err = addSetLoggerMiddleware(stack, options); err != nil {
    107 		return err
    108 	}
    109 	if err = addClientRequestID(stack); err != nil {
    110 		return err
    111 	}
    112 	if err = addComputeContentLength(stack); err != nil {
    113 		return err
    114 	}
    115 	if err = addResolveEndpointMiddleware(stack, options); err != nil {
    116 		return err
    117 	}
    118 	if err = addRetry(stack, options); err != nil {
    119 		return err
    120 	}
    121 	if err = addRawResponseToMetadata(stack); err != nil {
    122 		return err
    123 	}
    124 	if err = addRecordResponseTiming(stack); err != nil {
    125 		return err
    126 	}
    127 	if err = addClientUserAgent(stack, options); err != nil {
    128 		return err
    129 	}
    130 	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
    131 		return err
    132 	}
    133 	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
    134 		return err
    135 	}
    136 	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
    137 		return err
    138 	}
    139 	if err = addOpStartDeviceAuthorizationValidationMiddleware(stack); err != nil {
    140 		return err
    141 	}
    142 	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartDeviceAuthorization(options.Region), middleware.Before); err != nil {
    143 		return err
    144 	}
    145 	if err = addRecursionDetection(stack); err != nil {
    146 		return err
    147 	}
    148 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
    149 		return err
    150 	}
    151 	if err = addResponseErrorMiddleware(stack); err != nil {
    152 		return err
    153 	}
    154 	if err = addRequestResponseLogging(stack, options); err != nil {
    155 		return err
    156 	}
    157 	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
    158 		return err
    159 	}
    160 	return nil
    161 }
    162 
    163 func newServiceMetadataMiddleware_opStartDeviceAuthorization(region string) *awsmiddleware.RegisterServiceMetadata {
    164 	return &awsmiddleware.RegisterServiceMetadata{
    165 		Region:        region,
    166 		ServiceID:     ServiceID,
    167 		OperationName: "StartDeviceAuthorization",
    168 	}
    169 }