If you would prefer to jump straight ahead to reference information for each endpoint in our OAuth
flow, you can find documentation
here.
1
Create a new app in the developer dashboard
2
Configure OAuth
Our next job is to enable OAuth 2.0 for the app. Head to the OAuth tab in your app’s settings and
enable OAuth 2.0 via the toggle at the top of the page.Next, configure the redirect URIs for your app. For our tutorial, we’ll use the following URL:Of course, for a real app, you’d also include a publicly available URL such as
https://my-app.com/integrations/attio/callback
.Lastly, we need to configure the app’s scopes. Heads to the scopes tab to enable these. For our
demonstration app, we’ll set tasks, user management, object configuration and records to “read” so
we can fetch a list of tasks and which users they are assigned to.3
Setup the Node.js project
Make a new directory and setup your new Node.js project inside it:Create a new file called You should now be able to run your app from the command line and visit it in your browser at
Run through the signup flow to ensure everything works as expected.
server.js
and add the following code:http://localhost:3050
:4
Add support for OAuth
To add support for OAuth, we need to ensure that our Node.js code has access to the OAuth client ID
and client secret.Create a new file called When we complete the OAuth flow, we’ll need a place to store the OAuth access token for each user.
Modify the code that creates the In a real app, you should encrypt these values before storing them. Access tokens are highly
sensitive data and should be stored securely.Next, we need to implement the OAuth flow itself. An OAuth flow consists of the following steps:A second route will handle the redirect back from Attio.Last, we need to ensure the user can navigate to the start of this flow. Let’s add a button to the
home page that redirects to the
.env
and add your app’s client ID and client secret. You can find these
in the OAuth tab in your app’s settings.users
table as follows:- Redirect to Attio’s OAuth authorization page when prompted by the user
- Handle the redirect back from Attio
- Exchange the authorization code for an access token
- Persist the access token
- Make API requests using the access token
/integrations/attio/connect
route.Please note, the example above stores a raw access token in the database. The access tokens that
we grant to your app are highly sensitive data and should be stored securely. Please ensure any
production apps you build encrypt the token before storing it.
5
Make a request to the Attio API and render the results
Now we have a token, all that remains is to make a request to the Attio API and render the results.To make a request to the Attio API, we need to call the right endpoint and pass in our new oauth
token in the
Authorization
header like so.6
Test your app
All that remains is to spin up your app and test it out!Run your app from the command line and visit it in your browser at
http://localhost:3050
.