Messenger Guide
Learn how to implement a custom Messenger authentication form into your application.
Step 1: Authenticate to Messenger
Make a POST request to this Unipile API endpoint or use the appropriate SDK Method.
const response = await client.account.connectMessenger({
username: "unipile",
password: "********"
})
todo
curl --request POST \
--url https://{YOUR_DSN}/api/v1/accounts \
--header 'X-API-KEY: {YOUR_ACCESS_TOKEN}' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"provider": "MESSENGER",
"username": "unipile",
"password": "********"
}
'
Step 2 : Handle 2FA checkpoint
If an Messenger account has the two-factor authentication activated, you will encounter a checkpoint through a 202 status. Here’s an example of a checkpoint response.
{
"object": "Checkpoint",
"account_id": "098dez89d",
"checkpoint": {
"type": "2FA"
}
}
In this case, a new Authentication Intent starts. **This intent last 5 minutes and checkpoints must be solved in
Step 3 : Solve 2FA checkpoint
To solve the 2FA checkpoint, make a POST request to the Unipile API using the Solve checkpoint endpoint or use an SDK Method by giving the account_id
returned by the first request
const response = await client.account.solveCodeCheckpoint({
provider: "MESSENGER",
account_id: "098dez89d",
code: "******",
});
todo
curl --request POST \
--url https://{YOUR_DSN}/api/v1/accounts/checkpoint \
--header 'X-API-KEY: {YOUR_ACCESS_TOKEN}' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"provider": "MESSENGER",
"account_id": "098dez89d",
"code": "******"
}
'
If you want to connect to Messenger via your application, the 2FA checkpoint will be encountered. Simply enter " in_app_validation " in code parameter and validate the connection on your device.
The response of this request will indicate if the account is successfully connected.
Step 4 : Handle Intent Timeout
If the user takes more than 5 minutes to solve the checkpoint, the account will not be connected. Any subsequent request to solve a checkpoint outside a 5 minutes time frame will first respond a 408 - Request Timeout, then a 400 - Bad Request as the Authentication Intent will self destroy.
Updated 4 months ago