Skip to main content
Once your application has successfully configured authentication settings, users can update and take actions with resources they own per the following flow.
1

Request a user key for a user

Make a request to the Privy API with the user’s access token to request a user key. If the token is valid per your configured authentication settings, Privy will return a time-bound user key that can be used to sign requests.
2

Sign the request with the user key

Given the returned user key, sign the request to update or take actions with a resource the user owns.
3

Pass the signature in request headers

Lastly, pass the signature from the user key in a privy-authorization-signature header for the request. Privy will verify the signature and execute the request only if the signature is valid.
Follow the guide below to learn how to request and use user keys from the Privy API.
  • NodeJS
  • NodeJS (server-auth)
  • Java
  • REST API

Set the authorization context to use the user’s keypair

Given the user’s access token, the NodeJS SDK handles requesting the user key via the Privy API under the hood. Use the authorization context builder to set the user JWT, and pass it into wallet API functions that require owner’s authorization, by setting the user_jwts property.
const authorizationContext: AuthorizationContext = {
  user_jwts: ['insert-user-jwt']
};
Wallet requests on the wallets owned by the user can now be made by passing in this newly created authorization context on the call to the PrivyClient.
Example: Sign a message with the user's wallet
try {
  // With the authorization context, this method automatically signs the request.
  const response = await privyClient
    .wallets()
    .ethereum()
    .signMessage(walletId, {
      message: 'Hello, Ethereum.',
      authorization_context: {
        user_jwts: ['insert-user-jwt']
      }
    });

  const signature = response.signature;
} catch (error) {
  console.error(error);
}