We’ve migrated our documentation to a new site, which means some URLs have changed.
Subscriptions

How to get user data such as email or name from the Piano SDK

It's possible to get user data with the use of the JWT token for the Piano PHP SDK as well as the mobile SDK. The individual SDK libraries are available here.

The JWT will be the value of the __utp cookie so you would get access to the user data either by grabbing __utp of the document.cookie in the browser and doing something like this with the value, which is base-64 encoded:

atob(utpCookieValue.split('.')[1]);

This should give you the JWT claims in a JS object.

Alternatively, if you're working in PHP it's probably more preferable to get access to the user data by pulling it off of $_COOKIE['__utp']. First-party cookies should go through with your backend requests.

For the mobile SDK, you can decrypt the JWT to get the user details.

Last updated: