Check User Auth
How to
Authentication
Test that the API and auth are working.
GET
Check User Auth
Introduction
There are two methods that can be used to authenticate with@zapier/ai-actions:
- API Key: If you plan on only using the AI Actions client to interact with AI Actions on your behalf
- OAuth: If you plan on creating an OAuth app to allow users to interact with AI Actions on their behalf
API Key
Follow the steps below to create your API key:- Log in or sign up to Zapier.
- Connect your Zapier account to the
customintegration app. - Your API key can be retrieved from the Credentials page.
OAuth
Creating an OAuth app
Click here to create an OAuth app
Click here to create a new OAuth app to use for authenticating with AI
Actions.
Authenticating with OAuth
Getting a token
Your OAuth client can be used with the PKCE flow to authenticate with AI Actions using aBearer token.
To begin this process, you first need to generate a code verifier and a code challenge.
Here is some sample code in TypeScript to do this:
redirect_uri you provided with a code query parameter.
You can then exchange this code for a token, using the verifier that you generated previously:
access_token can then be used to make API calls to AI Actions:
Quick account creation
Since your users may not already have a Zapier account, we offer a quick account creation flow that allows users to create a Zapier account and connect their account to your app in one step. To use this flow, first generate the/oauth/authorize URL as outlined above.
Then, get the account creation URL for your OAuth client:
login_link, they will go through a quick Zapier account creation flow. If the provided email address is already associated with a Zapier account, they will be asked to log in.
Users will receive a follow-up email from Zapier to confirm their email address and to let them set a password for the account.
The user will then see the AI Actions OAuth consent screen and be redirected back to your redirect_uri with a code query parameter, which can be exchanged for an access token as outlined above.
Refreshing tokens
Afterexpires_in seconds, the access_token will expire. To get a new token, you can use the refresh_token that was returned when you got the original token:
Authorization: Bearer ... header.