Exemplo n.º 1
0
func ExampleCognitoIdentity_UpdateIdentityPool() {
	svc := cognitoidentity.New(session.New())

	params := &cognitoidentity.IdentityPool{
		AllowUnauthenticatedIdentities: aws.Bool(true),                 // Required
		IdentityPoolId:                 aws.String("IdentityPoolId"),   // Required
		IdentityPoolName:               aws.String("IdentityPoolName"), // Required
		DeveloperProviderName:          aws.String("DeveloperProviderName"),
		OpenIdConnectProviderARNs: []*string{
			aws.String("ARNString"), // Required
			// More values...
		},
		SupportedLoginProviders: map[string]*string{
			"Key": aws.String("IdentityProviderId"), // Required
			// More values...
		},
	}
	resp, err := svc.UpdateIdentityPool(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Exemplo n.º 2
0
func ExampleCognitoIdentity_UnlinkIdentity() {
	svc := cognitoidentity.New(session.New())

	params := &cognitoidentity.UnlinkIdentityInput{
		IdentityId: aws.String("IdentityId"), // Required
		Logins: map[string]*string{ // Required
			"Key": aws.String("IdentityProviderToken"), // Required
			// More values...
		},
		LoginsToRemove: []*string{ // Required
			aws.String("IdentityProviderName"), // Required
			// More values...
		},
	}
	resp, err := svc.UnlinkIdentity(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Exemplo n.º 3
0
func ExampleCognitoIdentity_DescribeIdentity() {
	svc := cognitoidentity.New(session.New())

	params := &cognitoidentity.DescribeIdentityInput{
		IdentityId: aws.String("IdentityId"), // Required
	}
	resp, err := svc.DescribeIdentity(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Exemplo n.º 4
0
func ExampleCognitoIdentity_ListIdentityPools() {
	svc := cognitoidentity.New(session.New())

	params := &cognitoidentity.ListIdentityPoolsInput{
		MaxResults: aws.Int64(1), // Required
		NextToken:  aws.String("PaginationKey"),
	}
	resp, err := svc.ListIdentityPools(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Exemplo n.º 5
0
func ExampleCognitoIdentity_DeleteIdentities() {
	svc := cognitoidentity.New(session.New())

	params := &cognitoidentity.DeleteIdentitiesInput{
		IdentityIdsToDelete: []*string{ // Required
			aws.String("IdentityId"), // Required
			// More values...
		},
	}
	resp, err := svc.DeleteIdentities(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Exemplo n.º 6
0
func ExampleCognitoIdentity_UnlinkDeveloperIdentity() {
	svc := cognitoidentity.New(session.New())

	params := &cognitoidentity.UnlinkDeveloperIdentityInput{
		DeveloperProviderName:   aws.String("DeveloperProviderName"),   // Required
		DeveloperUserIdentifier: aws.String("DeveloperUserIdentifier"), // Required
		IdentityId:              aws.String("IdentityId"),              // Required
		IdentityPoolId:          aws.String("IdentityPoolId"),          // Required
	}
	resp, err := svc.UnlinkDeveloperIdentity(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Exemplo n.º 7
0
func ExampleCognitoIdentity_SetIdentityPoolRoles() {
	svc := cognitoidentity.New(session.New())

	params := &cognitoidentity.SetIdentityPoolRolesInput{
		IdentityPoolId: aws.String("IdentityPoolId"), // Required
		Roles: map[string]*string{ // Required
			"Key": aws.String("ARNString"), // Required
			// More values...
		},
	}
	resp, err := svc.SetIdentityPoolRoles(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Exemplo n.º 8
0
func ExampleCognitoIdentity_LookupDeveloperIdentity() {
	svc := cognitoidentity.New(session.New())

	params := &cognitoidentity.LookupDeveloperIdentityInput{
		IdentityPoolId:          aws.String("IdentityPoolId"), // Required
		DeveloperUserIdentifier: aws.String("DeveloperUserIdentifier"),
		IdentityId:              aws.String("IdentityId"),
		MaxResults:              aws.Int64(1),
		NextToken:               aws.String("PaginationKey"),
	}
	resp, err := svc.LookupDeveloperIdentity(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Exemplo n.º 9
0
func ExampleCognitoIdentity_GetId() {
	svc := cognitoidentity.New(session.New())

	params := &cognitoidentity.GetIdInput{
		IdentityPoolId: aws.String("IdentityPoolId"), // Required
		AccountId:      aws.String("AccountId"),
		Logins: map[string]*string{
			"Key": aws.String("IdentityProviderToken"), // Required
			// More values...
		},
	}
	resp, err := svc.GetId(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Exemplo n.º 10
0
func ExampleCognitoIdentity_GetOpenIdTokenForDeveloperIdentity() {
	svc := cognitoidentity.New(session.New())

	params := &cognitoidentity.GetOpenIdTokenForDeveloperIdentityInput{
		IdentityPoolId: aws.String("IdentityPoolId"), // Required
		Logins: map[string]*string{ // Required
			"Key": aws.String("IdentityProviderToken"), // Required
			// More values...
		},
		IdentityId:    aws.String("IdentityId"),
		TokenDuration: aws.Int64(1),
	}
	resp, err := svc.GetOpenIdTokenForDeveloperIdentity(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
Exemplo n.º 11
0
func init() {
	Before("@cognitoidentity", func() {
		World["client"] = cognitoidentity.New(smoke.Session)
	})
}
Exemplo n.º 12
0
package cognitoidentity_test

import (
	"testing"

	"github.com/bluet-deps/aws-sdk-go/aws"
	"github.com/bluet-deps/aws-sdk-go/awstesting/unit"
	"github.com/bluet-deps/aws-sdk-go/service/cognitoidentity"
	"github.com/stretchr/testify/assert"
)

var svc = cognitoidentity.New(unit.Session)

func TestUnsignedRequest_GetID(t *testing.T) {
	req, _ := svc.GetIdRequest(&cognitoidentity.GetIdInput{
		IdentityPoolId: aws.String("IdentityPoolId"),
	})

	err := req.Sign()
	assert.NoError(t, err)
	assert.Equal(t, "", req.HTTPRequest.Header.Get("Authorization"))
}

func TestUnsignedRequest_GetOpenIDToken(t *testing.T) {
	req, _ := svc.GetOpenIdTokenRequest(&cognitoidentity.GetOpenIdTokenInput{
		IdentityId: aws.String("IdentityId"),
	})

	err := req.Sign()
	assert.NoError(t, err)
	assert.Equal(t, "", req.HTTPRequest.Header.Get("Authorization"))