Skip to main content

Obtaining Logged In User

Overview

Harness the power of the Passport JS SUI SDK to access current user data, enabling a comprehensive understanding of user profiles by effectively managing data structures and secure authentication tokens.

Retrieve User Data

Access User Information

To retrieve user data, use the passport.getUser() method. This method fetches information about the currently logged-in user from the Credenza system. Implement it as follows:

typescript
const user = await passport.getUser();

Understand User Data Structure

Data Fields Explanation

UserType: Indicates the type of the authenticated user. Example value: aud.

email: The email address associated with the user's account. Example value: mavvad00@gmail.com.

exp: Expiration time of the token, represented as a Unix timestamp. Example value: 1726681735.

iat: Issued-at time of the token, represented as a Unix timestamp. Example value: 1726666975.

iss: The issuer of the token, indicating the authentication server. Example value: https://accounts.staging.credenza3.com.

login_type: Specifies the method used for login. Example value: credentials.

nonce: A unique identifier used to prevent replay attacks. Example value: GE4c6Sz9FGlZOKwi.

scope: Specifies the granted permissions. Example value: profile profile.write email phone blockchain.evm.write blockchain.evm.

sub: Subject identifier, unique to each user. Example value: 66e9e4b3af970d8aa42d2d64.

Token Types and Uses

Bearer tokens, a type of access token, are used to grant access to protected resources. In the context of user data retrieval, these tokens allow you to request user information securely and efficiently. Upon successful authentication, a Bearer token is issued, which you include in the Authorization header of your HTTP requests. This mechanism ensures that any request to retrieve user data is authenticated and authorized.

Within Credenza's system, Bearer tokens serve to facilitate real-time, contextual engagement with consumers. By integrating across digital, physical, and linear domains, these tokens help to provide a comprehensive view of user actions and attributes. This access enables personalized interactions and benefits, driving new revenue streams and enhancing user retention through detailed user behavior analysis.

Retrieve User Address

Access User Address Information

To retrieve the address of the currently logged-in user, use the passport.getAddress() method. This function fetches the user's address details from the Credenza system. Hereโ€™s an example of how to implement this method:

typescript
const address = await passport.getAddress();