If you need the UID, email, first or last name of a user and you’re using Identity Management, you are able to get it via the following function:
tp.pianoId.getUser()
A sample response can look like this:
aud: "XTSRGNiPZY"
confirmed: true
email: "test@piano.io"
email_confirmation_required: false
exp: 1631175839
family_name: "Doe"
firstName: "John"
given_name: "John"
iat: 1599639839
iss: "https://id.piano.io"
jti: "TIsmDAxE4Wqgdtzz"
lastName: "Doe"
login_timestamp: "1599639839891"
sub: "PNIJqDy5yqgdtzz"
uid: "PNIJqDy5yqgdtzz"
valid: true
For Piano Identity Linking, there are multiple approaches.
-
You can get the JWT token via the following function and decrypt it as needed:
tp.pianoIdLite.getToken() -
Use the function:
JSON.parse(atob(tp.pianoIdLite.getToken().split(".")[1]))to get the user's information directly.
Please note, that if you are using an asymmetric algorithm (A128KW or RSA_OAEP) to generate an encrypted JWT token (or a UserRef token), you would need to use the /anon/user/get endpoint with the tp.api.callApi() method to retrieve the user’s information as described here.
The fields specific to Piano Identity Linking are listed below:
"iss" => "https://www.piano.io",
"aud" => "1234",
"iat" => $issuedAt,
"exp" => $expAt,
"jti" => strval(rand(1, 99999999)),
"email" => $userEmail,
"sub" => strval($userID),
"first_name" => $userFirstName,
"last_name" => $userLastName