How to integrate Facebook API with Memberstack for automated posting while securely storing user access tokens? Answered

Post author
Graham Ferguson

I’ve asked a few times but not had a clear answer about what is possible using Memberstack. In simple terms users will be able to do the following (based on ChatGPT):

Memberstack primarily handles user authentication and membership functionality. For posting Facebook posts on behalf of a customer, you would need to integrate additional tools or build custom functionalities within your web app. Here's a basic guide:

  • *User Authentication with Memberstack:

Set up user authentication using Memberstack to manage user accounts on your app.

  • *Facebook App Creation:

Create a Facebook App on the Facebook Developer portal and configure the necessary permissions for posting on behalf of a user.

  • *Facebook API Integration:
  1. Utilize Memberstack's features to store user-specific data, such as their Facebook credentials or access tokens.
  2. Use the stored data to make API calls to the Facebook Graph API for posting.
  • *Implement User Authorization:
  1. Develop a process for users to connect their Facebook accounts to your app.
  2. Retrieve and store the necessary Facebook access tokens securely for each user.
  • *Post Creation:
  1. Implement the logic to create and post content on Facebook using the stored access tokens.

Questions:

  1. Where would it be best to store the user access tokens?
  2. How to call the API and dynamically inject the specific users access token

Comments

2 comments

  • Comment author
    Raquel Lopez

    Hello,

    1. If you use Memberstack to authenticate your users, their resulting access tokens (JWT tokens), would be stored in a cookie or in local storage (depending your MS configuration) in the client (browser). You can look them up using your dev tools, it should be called _ms-mid or you can also get it via Memberstack API $memberstackDom.getMemberCookie() if you need to send it to a server...
    2. This is not an easy answer. If you plan to allow users to send posts to their Facebook while using your app, you'll first need to set up a server and start configuring all the integrations to send the token, decode it, then connect to facebook API, request for permissions to the user and then finally create the post... The token would travel via request like a tunnel. The chat GPT answer was accurate but all the actions should be set up in a server...

    It's not a typical DIY task, it will require programming or maybe look up if tools like Make or Zapier allow Facebook posting

    0
  • Comment author
    Graham Ferguson

    Raquel Lopez thanks.

    1. For Facebook as an example I would need to:- Have a button which can create a call an API to get an app access token and page access token which I would want to store on the user record or in airtable (https://developers.facebook.com/docs/facebook-login/guides/access-tokens/)
    2. My plan initially is to use Zapier or Make - I really just need to figure out step 1 and avoid having to use something like Wized
    0

Please sign in to leave a comment.