Handling Account Connection Redirects and Webhooks

Use the callback or webhooks to know the status of account connections after redirecting your users to the auth URL.

Integrating social media OAuth flows into your application requires clear visibility into connection outcomes. With Post for Me, you can reliably manage account connection redirects and webhooks to keep your frontend and backend perfectly in sync.

Here is a breakdown of how the account connection redirect flow and webhook processes work.

The Authorization Redirect Flow

Definition: The post-authorization redirect is the process of sending the user back to your application's configured callback URL after they interact with the social platform's login screen.

How it works

We will always redirect the user back to your callback URL, regardless of whether the connection was a success or a failure. Appended to this redirect URL will be several specific parameters you can read on your frontend or backend:

  • provider
  • projectId
  • isSuccess
  • accountIds
  • failedAccountIds
  • error

Handling Failures

If the authorization fails or the user explicitly cancels the authorization on the platform, they are still redirected back to your app. In this scenario, the isSuccess parameter will be set to false, and there will be a descriptive message provided in the error parameter.

The User Experience

If a user clicks "connect" but never returns to your redirect URL, it means they abandoned the session entirely in the middle of the flow. You can handle this gracefully in your UI by treating a long period of inactivity on the connection screen as an abandoned attempt.

Managing Authorization Links

Definition: Authorization links are the secure URLs generated by the API to initiate the connection process for a specific platform.

How it works

Authorization links do not have a set expiration time. However, to ensure the most secure and reliable connection process, they should not be cached or reused across different sessions.

The Requirement: You should generate a new Authorization URL for each individual connection attempt. The best practice is to call the API to generate the link exactly when the user clicks the "Connect" button in your UI, rather than pre-generating them.

Tracking Success with Webhooks

Definition: Webhooks provide a way for your server to receive real-time, asynchronous notifications when specific events occur within your Post for Me project.

How it works

To listen for successful account connections, you can subscribe to the social.account.created webhook event. Whenever a user successfully completes the OAuth flow and their account is added to your project, we will send a POST request to your webhook URL containing the new account data.

The Strategy: It is important to note that this specific webhook event will only trigger for accounts that have been connected successfully. We do not send webhook notifications for authorization failures or cancellations. To determine and handle connection failures, your application must rely entirely on reading the isSuccess and error parameters passed to your callback URL during the redirect.

Start coding today
Sign up for an account and start integrating social media posting, feeds, and metrics into your product.