In this tutorial, you'll learn how to connect to APIs using bearer token authentication in Airtable. Though we'll use GitHub's API in this tutorial, you can apply the steps you'll learn to other APIs that use bearer tokens for authorization.
A bearer token is a secret text value that API services use to authorize users. You can think of it like a password for the API. Many API services allow users to generate bearer tokens after they've signed up. The users can then access the APIs as long as they include the bearer token every time they make an API request.
In the upcoming section, we'll use GitHub's fine-grained personal access tokens to fetch the authenticated user's profile information.
If you already have a bearer token, you can skip this section!
GitHub's fine-grained personal access tokens are bearer tokens that users can configure to access specific API endpoints and resources. We'll create a fine-grained token with the default configuration:
1. Login to GitHub, click your profile image in the top-right corner of the screen, then click Settings.
2. Scroll down the left sidebar, then click <> Developer settings.
3. Open the Personal access tokens dropdown, then click Fine-grained tokens.
4. Click Generate new token.
5. Name the token "Profile info", then give it the following description: "Returns the profile information for the authenticated user."
6. Scroll down the page, then click Generate token.
7. Copy and paste the token somewhere safe, or leave the browser tab open so you can copy it when we use it in Data Fetcher. You can regenerate a token if you forget to copy it.
Now that we've generated the token, let's install Data Fetcher.
1. Add the Data Fetcher extension to your Airtable base.
2. Once you’ve added the extension, sign in to Data Fetcher or sign up if you don’t have an account.
3. Once you've logged in to Data Fetcher, click Create your first request.
Follow these steps to set up the request:
1. Under Application, select Custom.
2. Name the request "Fetch GitHub profile data".
3. Enter https://api.github.com/user under URL. Make sure the request's method is GET.
4. Click Authorization, then select Bearer Token.
5. Copy and paste your fine-grained personal access token into the Token field. If you're not using GitHub, check your chosen API's documentation to find your bearer token.
6. Click the Headers tab, then click + Add.
7. Add a User-Agent header with "Data Fetcher" as the value. GitHub requires this header to identify who is making the request. If you're not using the GitHub API, check your API's documentation to see what headers (if any) you need to add.
8. Click Save and Run in the bottom right corner.
Once you've completed the previous steps, Data Fetcher will take you to Response field mapping. On this page, you'll select the fields you want to import from the response data.
We're going to import the "Login" field.
Click Existing field under "Login", then select "Name" from the dropdown.
Click Save and Run in the bottom right corner.
Check your table to see the results.
That's all for this tutorial. Here's a summary of how to connect to an API with a bearer token in Airtable:
Check out our blog to see how you can use Data Fetcher and Airtable to import data from different APIs.
Oct 7, 2024
•Zayyad Muhammad Sani
•Custom RequestsData FetcherSep 20, 2024
•Zayyad Muhammad Sani
•Custom RequestsAug 20, 2024
•Zayyad Muhammad Sani
•Custom Requests