Skip to content

Genies Avatar Authentication#

Modes of authenticating a user#

There are multiple ways of linking a user with their Genies Avatar:

  • Using the pre-built Sign Up/Sign In forms in the Genies Avatar Creator
  • Creating custom anonymous users (requires Genies approval)

Using the Genies Avatar Creator#

The easiest way to link your users with their Genies Avatar is to use the Avatar Creator

When using the Avatar Creator users can create an Avatar Account and associate their personal avatar with it. Every Avatar created this way will get an associated UserId that needs to be stored and associated with the user of the Partner app.

Screenshot Screenshot

Using anonymous managed user accounts#

Another way of linking users with their Genies Avatar is using a Partner API Account to create managed user accounts. The managed user accounts are anonymous and all user data is opaque to Genies (no personal user data is sent to Genies).

For more information about using the Partner API Account check the Managed Users section

The Partner API Account#

In order to created managed accounts for your users, you need to request specific access to this feature while applying for your Partner Account.

When approved access to the managed accounts feature, you'll receive credentials for a Partner API Account.

Partner API Account Authentication#

In order to manage anonymous user accounts you need to authenticate with your provided Partner API Account credentials and get the associated IdToken and RefreshToken.

Genies provides multiple ways of authenticating your Partner API Account:

IdToken and RefreshToken#

The IdToken is used to authenticate all requests made by the Partner to the Avatar API and the Anonymous Users API. It's usually sent as part of the Authorization header.

The RefreshToken is used to authenticate all interactions with the Avatar Creator

The IdToken and RefreshToken are provided when signing in with a Partner API account

Partner API Account HTTP Authentication#

The Avatar Authentication API uses AWS Cognito to handle authentication. The IdToken provided by the authentication flow is used to authenticate all the subsequent actions with the Avatar API.

HTTP Request URL#

The Authentication API URL is:

https://cognito-idp.us-west-2.amazonaws.com/

Requests and response formats#

The Avatar Authentication API uses HTTP POST requests with JSON arguments and JSON responses

HTTP Header Contents#

The Avatar Authentication API requires the following information in the headers of an HTTP request:

  • Content-Type

    Specifies JSON and the version, for example, Content-Type: application/x-amz-json-1.0

  • X-Amz-Target

    Specifies the Cognito Action type, for example: 'X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth'

HTTP Request Body#

The Avatar API requests require the request body to be sent in JSON format.

HTTP Responses#

The Avatar API requests include JSON-formatted data in the response

Errors#

When you send requests to and get responses from the Authentication API, you might encounter two types of API error:

  • Client errors:

    Client errors are indicated by a 4xx HTTP response code. Client errors indicate that Authentication API found a problem with the client request, such as an authentication failure or missing required parameters.

  • Server errors:

    Server errors are indicated by a 5xx HTTP response code, and need to be resolved by the Amazon Cognito service

For each API error, the Authentication API returns the following values:

  • A status code, for example, 400
  • An error code, for example, ValidationException
  • An error message, for example, 1 validation error detected: Value at 'password' failed to satisfy constraint: Member must have length greater than or equal to 6

Partner API Account Sign In#

To use your Partner API Account you should sign in and get the IdToken used to authenticate all other Avatar SDK interactions.

To sign in you should use the X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth action header and POST a JSON containing the AuthFlow key set to USER_PASSWORD_AUTH and an AuthParameters object with the USERNAME and PASSWORD keys.

Example

curl --location --request POST 'https://cognito-idp.us-west-2.amazonaws.com/' \
--header 'X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth' \
--header 'Content-Type: application/x-amz-json-1.1' \
--data-raw '{
    "AuthFlow": "USER_PASSWORD_AUTH",
    "ClientId": "YOUR_CLIENT_ID",
    "AuthParameters": {
        "USERNAME": "testuser@genies.com",
        "PASSWORD": "exampleToughPassword"
    }
}'

Response

HTTP/1.1 200 OK
Date: Thu, 21 Jan 2021 18:39:38 GMT
Content-Type: application/x-amz-json-1.1
Content-Length: 3879
Connection: keep-alive
x-amzn-RequestId: 0d716321-5de1-4a8a-87cf-6aca1aa47c89

{
    "AuthenticationResult": {
        "AccessToken": "eyJraWQiOiJ1Wnh4cHB2VGVvVFJURWZxeGpnZU1OVHd1XC9oQld3U29xMThOa2duQ0xvZz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJiNDRmYWEyZS0wMGI1LTQ5ZjItOWZiNC03ZWNjZTEzZjU0OGUiLCJldmVudF9pZCI6IjA2NjNlNWIxLTMxNTctNDEzNC04MmYzLWE4NGUwZGNiNGQyYiIsInRva2VuX3VzZSI6ImFjY2VzcyIsInNjb3BlIjoiYXdzLmNvZ25pdG8uc2lnb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rurCgbqnFFfBSeqgTr48G95kWhYMlk1k28xs3DBmvNqbrsXrMmk2ZGcpy_TvA58-T-x5TPMo7bpPOSzPcGoJLadpVDv7lTuaUc8CY7L3Un1A1wifiJpY-O7d3wP8Jbmiq3b9NS2sB76h8t8ifVfZcbE20ECI_1-tD6Vw9lhYa6e3Vw3xNPLej0O6xWNR4EAgRKjcYikqfrkHhuWU-cCX513WiVRpoLl-9SS5pqELlLjYR2BJeV7-kVXE0Ly8jePcFut6GcE1P.miEFKs02GC-tXwUmvk0faw",
        "TokenType": "Bearer"
    },
    "ChallengeParameters": {}
}

Errors#

  • NotAuthorizedException: Incorrect username or password.

Refreshing the IdToken#

The IdToken provided when signing in expires after 1 day and needs to be refreshed using the RefreshToken. The RefreshToken has a validity of 30 days. To refresh the tokens you should POST a JSON containing the AuthFlow key set to REFRESH_TOKEN_AUTH and a AuthParameters object containing the RefreshToken.

Example

curl --location --request POST 'https://cognito-idp.us-west-2.amazonaws.com/' \
--header 'X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth' \
--header 'Content-Type: application/x-amz-json-1.1' \
--data-raw '{
    "AuthFlow": "REFRESH_TOKEN_AUTH",
    "ClientId": "YOUR_CLIENT_ID",
    "AuthParameters": {
        "REFRESH_TOKEN": "eyJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiUlNBLU9BRVAifQ.RsNP_jdQ-ocBqevwXhpd_mYX2353asFU1ct2yKAnNqTycxxy5mAyTxEX2-60AjxPYmnXLA3l4P9FyKWyPenuYMt0fMIXJZjJ62ZYuKbnIaSBKFSdQPzDCEqCzaQr-vhdJEux4gwMkvnq0Medw7R-RokR3Y_vpl-XGPz3XKKSYycfNxW4YQQ5hlkAoX7Ni4ocMhVLE7hvw49aFWC4mVwmCmpacegMJDepTfTG5mtCt77VtlL3ZwWgXTEX8QTX9EIbDiFJ8k4lks6o8Ci99Spe-epvOrDyW7ZSov5j8ZYzCU7i6w7nJwwIAleFxBg-ogC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EpQRpy6RqpMEIgrNgZOWYzHOiX7BI_c9-tGuLoeoThe-BLCRlxhF4EvKccEUP7pwRxg9mX-BfFLAhRmnqX8iyN-1hcNMxqARaBOmYTg-XChP57iyPgJRidtBW68_KtVzmTFDWzE-U3v6MntjChCOefNLpy_W7dP4BeCFuiv5lQ_JkPK6hLhwbnb_Bml1BdCgoP46nURw",
        "TokenType": "Bearer"
    }
}

Errors#

  • NotAuthorizedException: Invalid Refresh Token