Swift: Retrieve a user
- This method is useful for checking if the user is authorized because it validates the user's access token JWT on the server.
- Fetches the user object from the database instead of local session.
- Should be used only when you require the most current user data. For faster results,
session.user
is recommended.
Examples
Get the logged in user with the current existing session
let user = try await supabase.auth.user()
Get the logged in user with a custom access token jwt
let user = try await supabase.auth.user(jwt: "custom-jwt")
Get current user
let user = supabase.auth.currentUser