Skip to main content

Profile

The Profile module provides functionality to retrieve and manage user profile information in the Datalayer platform. It allows you to access authenticated user details such as display name, email, user handle, and role information.

Profile Class

The Profile class represents a user profile with the following attributes:

  • display_name: The user's display name
  • email: The user's email address
  • first_name: The user's first name
  • handle: The user's unique handle/username
  • last_name: The user's last name
  • uid: The user's unique identifier
  • roles: List of roles assigned to the user

Get User Profile

You can retrieve the current authenticated user's profile using the get_profile() method:

from datalayer_core import DatalayerClient

# Initialize the client with authentication
client = DatalayerClient(token="your-token-here")

# Get the current user's profile
profile = client.get_profile()

# Access profile information
print(f"Display Name: {profile.display_name}")
print(f"Email: {profile.email}")
print(f"Handle: {profile.handle}")
print(f"User ID: {profile.uid}")
print(f"Roles: {profile.roles}")

Profile Attributes

Basic Information

from datalayer_core import DatalayerClient

client = DatalayerClient()
profile = client.get_profile()

# Personal information
print(f"Name: {profile.first_name} {profile.last_name}")
print(f"Display Name: {profile.display_name}")
print(f"Email: {profile.email}")
print(f"Handle: @{profile.handle}")

User Identification

from datalayer_core import DatalayerClient

client = DatalayerClient()
profile = client.get_profile()

# Unique identifiers
print(f"User ID: {profile.uid}")
print(f"Handle: {profile.handle}")

Role Information

from datalayer_core import DatalayerClient

client = DatalayerClient()
profile = client.get_profile()

# Check user roles and permissions
print(f"User Roles: {profile.roles}")

# Check if user has specific role
if "admin" in profile.roles:
print("User has admin privileges")

Notes

  • Profile information is retrieved from the Datalayer IAM (Identity and Access Management) service
  • Ensure you have a valid authentication token before attempting to retrieve profile information
  • Profile data is cached and may not reflect real-time changes until the session is refreshed
  • The whoami endpoint requires proper authentication and network connectivity to the Datalayer platform