Skip to content

Auth Schemes

Auth is used to authenticate requests from Aiuta SDK to API with your credentials.

Using JSON Web Tokens (JWT) is the most flexible and secure way to access Aiuta services, while the ApiKey authentication method is best used for server-side integration. But it's up to you. Read more about API Authentication.

Auth

JwtAuth {
  subscriptionId: String // (1)!
  getJwt: Callback(Map<String: String>) => String // (2)!
}
  1. Should be provided for the SDK to make unsecured requests related to your account.

    Please see Obtaining credentials for instructions on how to get your subscriptionId

  2. The implementation of this method should securely generate the JWT on the server side and subsequently return it to the SDK.

    Returns

    Non-empty string representing the generated JWT

    Throws

    An error if the JWT cannot be generated.

    If an error is thrown, the SDK will be unable to complete the tryOn request and will display an error message to the user

Details

This method is invoked by the SDK each time a tryOn request necessitates authentication through a JSON Web Token.

The SDK will provide a set of key-value pairs that represent the parameters of the request requiring a JWT. These parameters include identifiers like a uploaded_image_id and product_id and can be used for associating the JWT with the specific image and product involved in the tryOn request. This ensures that the generated token is tailored specifically to the request being processed, enhancing security and relevance.

Sequence diagram

sequenceDiagram
    autonumber
    actor USR as ⠀<br>User
    participant APP as Your<br>App
    participant BE as Your<br>Backend
    participant SDK as Aiuta<br>SDK
    participant API as Aiuta<br>Backend
    participant GS as Storage
    note over GS: Aiuta or Yours

    USR->>SDK: Start some action
    activate SDK
    SDK->>APP: Request JWT (params)
    APP->>BE: Request new JWT (params)
    BE->>BE: Generate JWT
    Note over BE: Validating the request parameters
    BE-->>APP: Return generated JWT
    APP-->>SDK: Provide JWT
    SDK->>API: Make request
    Note over SDK,API: Authorization: Bearer <token>
    API->>API: Validate JWT

    break JWT is invalid
    rect
        API-->>SDK: Retun 401 Unauthorized
        SDK-->>USR: Show something went wrong
    end
    end

    API-->>SDK: Return response
    SDK-->>USR: Provide UI feedback / result
    deactivate SDK

The subscriptionId is used to authenticate requests that do not require secure transmission. It acts as a key to ensure that the requests are properly linked to your subscription and account.

Sequence diagram

sequenceDiagram
    autonumber
    actor USR as ⠀<br>User
    participant APP as Your<br>App
    participant BE as Your<br>Backend
    participant SDK as Aiuta<br>SDK
    participant API as Aiuta<br>Backend
    participant GS as Storage
    note over GS: Aiuta or Yours

    USR->>SDK: Start some action
    activate SDK
    SDK->>SDK: Add Subscription ID<br>to the request Headers
    SDK->>API: Make request
    Note over SDK,API: x-user-id: <subscription_id>
    API->>API: Match Subscription ID
    API-->>SDK: Return response
    SDK-->>USR: Provide UI feedback / result
    deactivate SDK
ApiKeyAuth {
  apiKey: String
}

Details

Please see API documentation Obtaining credentials section for instructions on how to get your apiKey

The apiKey is used to authenticate all outgoing requests from the Aiuta SDK to the Aiuta API. This key ensures that the requests are linked to your account, allowing the SDK to access the necessary resources and services provided by Aiuta.

Sequence diagram

sequenceDiagram
    autonumber
    actor USR as ⠀<br>User
    participant APP as Your<br>App
    participant BE as Your<br>Backend
    participant SDK as Aiuta<br>SDK
    participant API as Aiuta<br>Backend
    participant GS as Storage
    note over GS: Aiuta or Yours

    USR->>SDK: Start some action
    activate SDK
    SDK->>SDK: Add Api Key<br>to the request Headers
    SDK->>API: Make request
    Note over SDK,API: x-api-key: <api_key>
    API->>API: Check Api Key
    API-->>SDK: Return response
    SDK-->>USR: Provide UI feedback / result
    deactivate SDK