Getting the Identity
The getWallet
function in the SDK returns the identity
of the user. The user might be asked to go through a verification process before the identity
is returned.
This function returns the same response as the Get User Identity API endpoint.
{
"status": "SUCCESS",
"wallet": {
"did": "0x5fce1e85aa30d8b96bc3737f896d7b5b2a3ff47dc85b919fea052b282170cb0d"
}
}
Use Get User Identity API endpoint instead
For lower user friction, we recommend using the Get User Identity API endpoint instead of the SDK. The Get User Identity API endpoint doesn't require user verification.
The SDK operation will always require user verification unless you provide a user when initializing the SDK
Identity format
The identity follows the Polygon ID DID format.
Calling SDK
Here are some sample code snippets to call the SDK:
await sdk.getWallet();
sdk.getWallet(
Callback(
onSuccess = { response: JsonResponse ->
Log.d("onSuccess", response.toString())
},
onFailure = { error: JsonResponse ->
Log.d("onFailure", error.toString())
},
),
)
sdk.getWallet(
callback: Callback(
onSuccess: { (result: JsonResponse) in
print("onSuccess")
print(result.description)
},
onFailure: { (error: JsonResponse) in
print("onFailure")
print(error.description)
}
)
)
await sdk.getWallet();
await sdk.getWallet();
On success, the callback onSuccess
or the Promise resolve
function is called with the response as a JSON
object. This is what the data looks like:
{
"status": "SUCCESS",
"wallet": {
"did": "0x5fce1e85aa30d8b96bc3737f896d7b5b2a3ff47dc85b919fea052b282170cb0d"
}
}
Here's a reference implementation of this code for JS SDK: https://jsfiddle.net/passbird/71dkng50/
Error status
Callback onFailure
or the Promise reject
function is called when the user cancels the operation or if there's an error. The error object contains a status field, a string indicating the status of the operation. Here's what the error object looks like:
{
status: "USER_REQUEST_DENIED"
}
Here's a table of all possible error status returned by the SDK
Status | Description |
---|---|
USER_REQUEST_DENIED | The user has denied the request. |
INVALID_EMAIL | The SDK has been initialized with an invalid user email. |
APP_ID_REQUIRED | No app-id was provided when initializing the SDK. You can find the app id in the MetaKeep Developer Console. |
APP_NOT_FOUND | The provided app-id is invalid. You can find the correct app-id in the MetaKeep Developer Console. |
SOMETHING_WENT_WRONG | An unknown error occurred. Please get in touch with us if you continue seeing this error. |
Ā© Copyright 2024, Passbird Research Inc.