In this tutorial, you'll learn how to get data from an OAuth 2.0 API in Airtable using Data Fetcher. Although we'll use GitHub's OAuth 2.0 API in this tutorial, you can apply the steps you'll learn to connect to any OAuth 2.0 API in Airtable.
OAuth 2.0 is an authorization standard that allows users to give third-party web services and applications access to their data and perform actions on their behalf. When you use the "Sign in with Google" option on a website or give a Facebook game access to your profile, that's OAuth 2.0 in action.
In this case, we'll give Data Fetcher access to import user profile data from GitHub's OAuth 2.0 API into an Airtable base.
Create a new table and name it "GitHub profiles". Then, rename the primary field to "Username" and delete the other fields.
We'll have to create an OAuth app in GitHub before we can use the API in Data Fetcher.
Follow these steps to create an OAuth app in GitHub:
1. Login to your GitHub account.
2. Click your profile image in the top-right corner of the screen, then click Settings.
3. Scroll down the left sidebar and click <> Developer settings.
4. Select OAuth apps from the left sidebar.
Make sure not to select GitHub apps. You can read about their differences in GitHub's documentation.
5. Click Register a new application.
Now, we'll fill in the details of the OAuth app.
1. Name the application "Data Fetcher".
2. Copy and paste https://oauth.datafetcher.com into Homepage URL.
3. Under Application description, enter "Allows users to import GitHub profile data into Airtable".
4. Copy and paste https://oauth.datafetcher.com/auth/callback into Authorization callback URL.
GitHub will redirect you to the callback URL when you authorize the OAuth app to make API requests.
5. Click Register application.
Before we move on to Data Fetcher, we'll generate a client secret, which is like a password we'll use alongside the client ID to use the OAuth app in Data Fetcher.
1. Click Generate a new client secret.
2. If you have two-factor authentication turned on, GitHub will ask for a 6-digit authentication code before generating the client secret. Copy and paste the code from your authenticator app, and GitHub will create the client secret.
3. Copy and paste the client secret somewhere safe, or leave the browser tab open so you can copy it when we use it in Data Fetcher. You can always generate a new secret if you forget to copy it.
We're all set to install Data Fetcher and create a request to connect to the OAuth app.
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. Click the Authorization tab and select OAuth under Type.
4. Click + New to create a new OAuth connection
5. Click Create custom OAuth connection at the bottom of the modal.
We'll now fill in the details of the OAuth connection.
1. Enter "GitHub" under Name.
2. Set Auth type to OAuth 2.
3. Copy and paste the URL https://github.com/login/oauth/authorize into Authorization URL.
4. Scroll down, then copy and paste the URL https://github.com/login/oauth/access_token into Token URL.
5. Copy and paste your client ID and client secret from the OAuth app's page on GitHub.
6. Enter "user,repo_deployment" under Scopes. These scopes tell GitHub the parts of the API we want to access. You can read more about OAuth app scopes in GitHub's documentation.
7. Copy and paste https://api.github.com
into the Base URL.
8. Leave the request headers as they are, then click Create connection.
A dialog will open asking you to authorize the OAuth app. Click Authorize and you'll be redirected to Data Fetcher.
Now that we're authenticated, we can make an API request.
We'll use GitHub API's user endpoint to get the username and profile URL of the GitHub account that created the OAuth app. Follow these steps to make the request:
1. Enter https://api.github.com/user under URL. Make sure the request's method is GET.
2. Click the Headers tab, then click + Add.
3. Add a User-Agent header with "Data Fetcher" as the value. GitHub requires this header to identify who is making the request.
4. 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.
In this case, we only want the username and GitHub profile URL.
Check your table to see the results.
That's all for this tutorial. We can summarize the steps for connecting to an OAuth 2.0 API in Airtable as follows:
Check out our blog to see what other things you can do with Data Fetcher and Airtable.
Oct 7, 2024
•Zayyad Muhammad Sani
•Custom RequestsData FetcherSep 20, 2024
•Zayyad Muhammad Sani
•Custom RequestsAug 20, 2024
•Zayyad Muhammad Sani
•Custom Requests