The Graph API is the primary way for third party applications to read and write to the Facebook social graph.
Go to siteimport { axios } from "@pipedream/platform"
export default defineComponent({
props: {
facebook_graph_api: {
type: "app",
app: "facebook_graph_api",
}
},
async run({steps, $}) {
return await axios($, {
url: `https://graph.facebook.com/me/`,
headers: {
Authorization: `Bearer ${this.facebook_graph_api.$auth.oauth_access_token}`,
},
})
},
})
Facebook Graph API uses OAuth authentication. When you connect your Facebook Graph API account, Pipedream will open a popup window where you can sign into Facebook Graph API and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Facebook Graph API API.
Pipedream requests the following authorization scopes when you connect your account:
GET
https://www.facebook.com/v22.0/dialog/oauth
?
client_id={{custom_fields.client_id}}
&
redirect_uri={{oauth.redirect_uri}}
&
state={{oauth.state}}
&
response_type=code
&
scope={{custom_fields.space_separated_scopes}}
POST
https://graph.facebook.com/v22.0/oauth/access_token
content-type: application/x-www-form-urlencoded
accept: application/json
client_id={{custom_fields.client_id}}
&
client_secret={{custom_fields.client_secret}}
&
redirect_uri={{oauth.redirect_uri}}
&
grant_type=authorization_code
&
code={{oauth.code}}
POST
https://graph.facebook.com/v22.0/oauth/access_token
content-type: application/x-www-form-urlencoded
accept: application/json
client_id={{custom_fields.client_id}}
&
client_secret={{custom_fields.client_secret}}
&
fb_exchange_token={{oauth.access_token}}
&
grant_type=fb_exchange_token