How to obtain the access token for the Facebook Ads source
To connect to the Facebook Ads API and begin importing data, follow the steps below.
Step 1: Sign In to the Meta for Developers Portal
Section titled “Step 1: Sign In to the Meta for Developers Portal”Visit the Meta for Developers site and log in with your Facebook account.
Step 2: Create a New App
Section titled “Step 2: Create a New App”Navigate to My Apps and click the Create App button.
Enter the App Name in the provided field.
Select Other as the use case.
Select Business as the app type and click Next.
Choose the appropriate Business Portfolio, then click the Create App button.
Step 3: Set Up Marketing API
Section titled “Step 3: Set Up Marketing API”Go to the new app. In your app dashboard, locate Marketing API and click Set Up.
Step 4: Get the temporary token
Section titled “Step 4: Get the temporary token”First, ensure your app is in Development Mode:
Please, build the authorization URL. Use the template below and replace YOUR_APP_ID
with your actual App ID.
- Go to App Settings → Basic
- Copy your App ID
- Also note your App Secret (you’ll need it in the next step)
https://www.facebook.com/v23.0/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=http://localhost:8080/&scope=ads_read,read_insights&state=abc123
Example:
https://www.facebook.com/v23.0/dialog/oauth?client_id=665881219608750&redirect_uri=http://localhost:8080/&response_type=code&scope=ads_read,read_insights&state=abc123
- Open the generated URL in your browser
- Make sure you are logged in with the account that has access to the desired ad account
- Click Connect
After authorization, you’ll be redirected to a URL like this (note the long code
parameter):
http://localhost:8080/?code=AQBg6el516UZN-YDhnsDQOWUYjbavjIkykWvj5PxAOhgiHikl8HB0WOJLXwxRd6joT5x9u7XnWWsH4GbbzOo_McT5EVHzZkTt-bvb7qwVsLRUbPqKdyYQor73NuXNFpLMHK9xQZE2ucII2JBTxS0sGdlMq9ndP533lSR9ES22NKyaDTH2x9WJ8X07vBczF5phTB36KXm0t25Nw1tm576GFvO9OsJ6ie6KYcY6ILt9-ogW3hPCgnAYU399TRkV2njvpBd7FtvRSNyh7qybL93ToVnp_9LrjeRPm0MzPPF9Tg2dehcJlaDpZ0OmxKx7w8EOD3Wpb0Irmuf3unsBM4FsIe0ljQ6TSZiSvfghfLpviIakK08h1ATu0UXJTRVWYjCJ9itOQ30CiaNq9Th5Evtt8IW&state=abc123#_=_
Copy and save the code value (everything after code=
up to &state=...
).
You will need this in the next step.
Step 5: Generate and Save the Access Token
Section titled “Step 5: Generate and Save the Access Token”Now, exchange the authorization code for an Access Token. Go to ReqBin or use Postman.
Send a POST
request to:
https://graph.facebook.com/v23.0/oauth/access_token
with the following parameters:
client_secret=YOUR_APP_SECRET&redirect_uri=http://localhost:8080/&code=CODE_FROM_THE_PREVIOUS_STEP
Click the Send button.
You should receive a response containing your Access Token.
Copy and securely save the generated Access Token.
This token will be required to authenticate your API requests.
Step 6: Use the Access Token
Section titled “Step 6: Use the Access Token”Once you have the access token, you can begin using it as described in the Getting Started guide.
Troubleshooting and Support
Section titled “Troubleshooting and Support”If you encounter any issues:
- Please visit Q&A first
- If you want to report a bug, please open an issue
- Join the discussion forum to ask questions or propose improvements