service.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cognitoidentity
  3. import (
  4. "github.com/aws/aws-sdk-go/aws"
  5. "github.com/aws/aws-sdk-go/aws/defaults"
  6. "github.com/aws/aws-sdk-go/aws/request"
  7. "github.com/aws/aws-sdk-go/aws/service"
  8. "github.com/aws/aws-sdk-go/aws/service/serviceinfo"
  9. "github.com/aws/aws-sdk-go/internal/protocol/jsonrpc"
  10. "github.com/aws/aws-sdk-go/internal/signer/v4"
  11. )
  12. // Amazon Cognito is a web service that delivers scoped temporary credentials
  13. // to mobile devices and other untrusted environments. Amazon Cognito uniquely
  14. // identifies a device and supplies the user with a consistent identity over
  15. // the lifetime of an application.
  16. //
  17. // Using Amazon Cognito, you can enable authentication with one or more third-party
  18. // identity providers (Facebook, Google, or Login with Amazon), and you can
  19. // also choose to support unauthenticated access from your app. Cognito delivers
  20. // a unique identifier for each user and acts as an OpenID token provider trusted
  21. // by AWS Security Token Service (STS) to access temporary, limited-privilege
  22. // AWS credentials.
  23. //
  24. // To provide end-user credentials, first make an unsigned call to GetId. If
  25. // the end user is authenticated with one of the supported identity providers,
  26. // set the Logins map with the identity provider token. GetId returns a unique
  27. // identifier for the user.
  28. //
  29. // Next, make an unsigned call to GetCredentialsForIdentity. This call expects
  30. // the same Logins map as the GetId call, as well as the IdentityID originally
  31. // returned by GetId. Assuming your identity pool has been configured via the
  32. // SetIdentityPoolRoles operation, GetCredentialsForIdentity will return AWS
  33. // credentials for your use. If your pool has not been configured with SetIdentityPoolRoles,
  34. // or if you want to follow legacy flow, make an unsigned call to GetOpenIdToken,
  35. // which returns the OpenID token necessary to call STS and retrieve AWS credentials.
  36. // This call expects the same Logins map as the GetId call, as well as the IdentityID
  37. // originally returned by GetId. The token returned by GetOpenIdToken can be
  38. // passed to the STS operation AssumeRoleWithWebIdentity (http://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html)
  39. // to retrieve AWS credentials.
  40. //
  41. // If you want to use Amazon Cognito in an Android, iOS, or Unity application,
  42. // you will probably want to make API calls via the AWS Mobile SDK. To learn
  43. // more, see the AWS Mobile SDK Developer Guide (http://docs.aws.amazon.com/mobile/index.html).
  44. type CognitoIdentity struct {
  45. *service.Service
  46. }
  47. // Used for custom service initialization logic
  48. var initService func(*service.Service)
  49. // Used for custom request initialization logic
  50. var initRequest func(*request.Request)
  51. // New returns a new CognitoIdentity client.
  52. func New(config *aws.Config) *CognitoIdentity {
  53. service := &service.Service{
  54. ServiceInfo: serviceinfo.ServiceInfo{
  55. Config: defaults.DefaultConfig.Merge(config),
  56. ServiceName: "cognito-identity",
  57. APIVersion: "2014-06-30",
  58. JSONVersion: "1.1",
  59. TargetPrefix: "AWSCognitoIdentityService",
  60. },
  61. }
  62. service.Initialize()
  63. // Handlers
  64. service.Handlers.Sign.PushBack(v4.Sign)
  65. service.Handlers.Build.PushBack(jsonrpc.Build)
  66. service.Handlers.Unmarshal.PushBack(jsonrpc.Unmarshal)
  67. service.Handlers.UnmarshalMeta.PushBack(jsonrpc.UnmarshalMeta)
  68. service.Handlers.UnmarshalError.PushBack(jsonrpc.UnmarshalError)
  69. // Run custom service initialization if present
  70. if initService != nil {
  71. initService(service)
  72. }
  73. return &CognitoIdentity{service}
  74. }
  75. // newRequest creates a new request for a CognitoIdentity operation and runs any
  76. // custom request initialization.
  77. func (c *CognitoIdentity) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  78. req := c.NewRequest(op, params, data)
  79. // Run custom request initialization if present
  80. if initRequest != nil {
  81. initRequest(req)
  82. }
  83. return req
  84. }