Search…
User Credentials
User credentials allow you to interact with the Sentiance API. You need a token and user to authorize requests and query the right data.

Get User and Token

If the SDK is initialized, you can get the userID and token as follows:
iOS
Android
1
NSString* userId = [[SENTSDK sharedInstance] getUserId];
2
[[SENTSDK sharedInstance] getUserAccessToken:^(NSString *token) {
3
NSString* accessToken = token;
4
} failure:^{
5
}];
Copied!
1
String userID = sentianceSdk.getUserId();
2
3
sentianceSdk.getUserAccessToken(new TokenResultCallback() {
4
@Override
5
public void onSuccess(Token token) {
6
String accessToken = token.getTokenId();
7
}
8
9
@Override
10
public void onFailure() {
11
}
12
});
Copied!
If the token has expired, the SDK will get a new access token before passing it to the callback.

Failure

Generally, this operation will complete instantly by returning a cached access token, but if a new token has to be obtained from the Sentiance API, there is a possibility it will fail.
Specifically, failure in this case can occur if there is no network connection that can be used to communicate with the Sentiance API.
Last modified 2yr ago
Copy link