11

The access token provided by Whatsapp cloud API expires in 24 hours. Is there a way to get a permanent access token?

There is an official link for getting a permanent token on the whatsapp website : Learn how to create a permanent token but it is another rabbit hole which does not state how to get permanent access token.

If someone has done this successfully, please help me and other frustrated developers :)

Dinesh Singh
  • 727
  • 1
  • 10
  • 22

2 Answers2

31

You need to set up a system user as the admin of your app. You can then generate never expiring access tokens for this system user.

Step by step guide to set it up:

  1. Add a system user to your facebook app if it doesn't exist yet. Make sure it has the admin role.
  2. On the same page, in the "Assigned Assets" section, check whether your app is listed here. If not, add your app via the "Add asset" button, granting "Full control" over your app.
  3. Add the system user to your Whatsapp account in the "People" section, granting "Full control" over your Whatsapp account
  4. Now click the "Generate new token" button for above system user which reveals a "Generate token" popup. Select the 2 permissions whatsapp_business_management and whatsapp_business_messaging and confirm
  5. A new access token is presented to you as a link. Click it and then store the generated token safely as it will not be stored for you by facebook. This token will not expire.
Lars Blumberg
  • 19,326
  • 11
  • 90
  • 127
  • I'm facing the bellow issue. Create System User: "You have been temporarily blocked from performing this action." – Harshad Panmand Feb 23 '23 at 06:26
  • @HarshadPanmand - I am also facing the issue - Create System User is giving a message : "You have been temporarily blocked from performing this action." Did you find any resolution? Please let me know. – Swamy Apr 14 '23 at 11:05
  • 1
    @Swamy, to create System User your app needs to be reviewed by Meta. – Harshad Panmand Apr 15 '23 at 15:48
0

You can get user access token from Facebook oauth using this link: https://www.facebook.com/v8.0/dialog/oauth?client_id=<app_id>&response_type=code%20token&redirect_uri=<redirect_url>&scope=whatsapp_business_management

client_id: App ID of your app on developer.facebook.com redirect_url: your url where access token will be appended (note: you have to add to "valid oauth redirect urls" of your app "Facebook Login => Settings") scope: whatsapp_business_management

Once the process is completed the access tokens will be appended to your redirect url.