Token Expire?

What is the problem for Token Expire?

[log] >> Time took to initilize the DI 20 Milis
[log] *** Request ***
[log] uri: https://apix.eu.amity.co/api/v3/sessions
[log] method: POST
[log] responseType: ResponseType.json
[log] followRedirects: true
[log] persistentConnection: true
[log] connectTimeout: 0:00:30.000000
[log] sendTimeout: 0:10:00.000000
[log] receiveTimeout: 0:01:00.000000
[log] receiveDataWhenStatusError: true
[log] extra: {}
[log] headers:
[log] content-type: application/json
[log] X-API-Key: b0e8cccccccccccccccccccccccc636b2c
[log] data:
[log] {“userId":"allerg.meridor@gmail.com”,“deviceId”:“cc024370-2f9f-11ee-97c0-ed3a74ecd74e”,“displayName”:“Kobi Meridor a”}
[log]
[log] >>>>> Token Expire

I disable and its working
Enable secure mode

To implement with secure mode enabled please refer to this section:

I am facing the same issue. I confirm secure mode is disabled.

AmitySocialCloudConsole → Settings → Integrations → Enable Secure Mode = OFF

[log] >> Time took to initilize the DI 34 Milis

[log] *** Request ***

[log] uri: https://apix.sg.amity.co/api/v3/sessions

[log] method: POST

[log] responseType: ResponseType.json

[log] followRedirects: true

[log] persistentConnection: true

[log] connectTimeout: 0:00:30.000000

[log] sendTimeout: 0:10:00.000000

[log] receiveTimeout: 0:01:00.000000

[log] receiveDataWhenStatusError: true

[log] extra: {}

[log] headers:

[log] content-type: application/json

[log] X-API-Key: b0eaecaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa25

[log] data:

[log] {“userId”:“b0eae10f6b88a56c4b6284490”,“deviceId”:“8e0432f0-4a00-11ef-880a-45c5676fab57”}

[log]

[log] >>>>> Token Expire

Hello @itsatifsiddiqui , Could you kindly provide some additional details about your use case and the platform you’re using, including the version?

I am using flutter, and the following version of amity_sdk.

amity_sdk: ^0.46.1

await AmityCoreClient.setup(
    option: AmityCoreClientOption(
      apiKey: apiKeyHere,
      showLogs: true,
    ),
    sycInitialization: true,
  );

  await AmityCoreClient.login('b0eae10f').submit();

When I call login().submit(), it doesn’t return the user. Instead, it shows the following output:

[log] >> Time took to initilize the DI 34 Milis
[log] *** Request ***
[log] uri: https://apix.sg.amity.co/api/v3/sessions
[log] method: POST
[log] responseType: ResponseType.json
[log] followRedirects: true
[log] persistentConnection: true
[log] connectTimeout: 0:00:30.000000
[log] sendTimeout: 0:10:00.000000
[log] receiveTimeout: 0:01:00.000000
[log] receiveDataWhenStatusError: true
[log] extra: {}
[log] headers:
[log] content-type: application/json
[log] X-API-Key: apiKeyHere
[log] data:
[log] {“userId”:“b0eae10f”,“deviceId”:“8e0432f0-4a00-11ef-880a-45c5676fab57”}
[log]
[log] >>>>> Token Expire

Expected Behavior:

The login().submit() call should return the user.

Actual Behavior:

The call logs the request details but does not return the user, showing a token expiration message instead.

Please look into this issue and provide guidance on how to resolve it.

Hello @itsatifsiddiqui , We recommend adding the Server Region to your code. Please refer to this example:


void setup() async {
  await AmityCoreClient.setup(
      option: AmityCoreClientOption(
        apiKey: 'apikey',
        httpEndpoint: AmityRegionalHttpEndpoint.SG,
      ),
      sycInitialization: true);
}

Please refer this document : Installation and Authentication | Amity Docs

Adding the httpEndpoint resolved the token expire issue.

But I am now getting a different error.

Here is the updated code snippet.

await AmityCoreClient.setup(
      option: AmityCoreClientOption(
        apiKey: apiKeyHere
        showLogs: true,
        httpEndpoint: AmityRegionalHttpEndpoint.EU,
      ),
      sycInitialization: true,
    );


    final user = await AmityCoreClient.login('b0eae10f6b88a56c4b6284490').submit();

Here is the new output.

[log] >> Time took to initilize the DI 38 Milis
[log] Here
[log] *** Request ***
[log] uri: https://apix.eu.amity.co/api/v3/sessions
[log] method: POST
[log] responseType: ResponseType.json
[log] followRedirects: true
[log] persistentConnection: true
[log] connectTimeout: 0:00:30.000000
[log] sendTimeout: 0:10:00.000000
[log] receiveTimeout: 0:01:00.000000
[log] receiveDataWhenStatusError: true
[log] extra: {}
[log] headers:
[log]  content-type: application/json
[log]  X-API-Key: apiKeyHere
[log] data:
[log] {"userId":"b0eae10f6b88a56c4b6284490","deviceId":"9c93b7f0-4ab4-11ef-ac7a-93fae843e5b8"}
[log] 
[log] *** DioException ***:
[log] uri: https://apix.eu.amity.co/api/v3/sessions
[log] 
[log] Error Caught
[log] _TypeError
[log] Null check operator used on a null value
[log] DioException [connection error]: The connection errored: Failed host lookup: 'apix.eu.amity.co' This indicates an error which most likely cannot be solved by the library.
      Error: SocketException: Failed host lookup: 'apix.eu.amity.co' (OS Error: nodename nor servname provided, or not known, errno = 8)

I tried testing the sessions API on
https://api-docs.amity.co/#/

  1. v3 API is marked deprecated in the docs.
  2. both v3/sessions and v4/sessions API works on the swagger.

But when I copy the CURL command provided by the swagger, it shows the following error.

Please look into this issue and provide guidance on how to resolve it.

Hello, regarding the DioException, we will pass it to the team for further investigation. As for the API issue, we are unable to reproduce the error you’re experiencing. Please see the example curls below and ensure that only valid data is passed in the call, avoiding the use of ‘string’.

curl --location 'https://apix.eu.amity.co/api/v4/sessions' \
--header 'accept: application/json' \
--header 'x-api-key: xxx' \
--header 'Content-Type: application/json' \
--data '{
  "userId": "test",
  "deviceId": "test1"
}'