getAuth()
The getAuth() helper retrieves the current user's authentication state from the request object.
Parameters
- Name
 request- Description
 The request object.
- Name
 opts?- Description
 An optional object that can be used to configure the behavior of the
getAuth()function. It accepts the following properties:secretKey?: A string that represents the secret key used to sign the session token. If not provided, the secret key is retrieved from the environment variableCLERK_SECRET_KEY.
- Name
 acceptsToken?- Type
 TokenType- Description
 The type of authentication token(s) to accept. Valid values are:
'session_token'- authenticates a user session.'oauth_token'- authenticates a machine request using OAuth.'machine_token'- authenticates a machine request.'api_key'- authenticates a machine request using API keys.
Can be set to:
- A single token type.
 - An array of token types.
 'any'to accept all available token types.
Defaults to
'session_token'.
Returns
getAuth() returns the Auth object. This JavaScript object contains important information like the current user's session ID, user ID, and organization ID. Learn more about the Auth object.
Usage
See the dedicated guide for example usage.
Feedback
Last updated on