facebook / facebook-java-business-sdk

Java SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
402 stars 332 forks source link

Application does not have permission for this action, Please retry this action in a few minutes #442

Open Denalda-lab opened 1 year ago

Denalda-lab commented 1 year ago

Which SDK version are you using?

<dependency>
    <groupId>com.facebook.business.sdk</groupId>
    <artifactId>facebook-java-business-sdk</artifactId>
    <version>18.0.2</version>
</dependency>

What's the issue?

Steps/Sample code to reproduce the issue

I want to invite a user to join a business manager account programmatically using Java. My App and the access token I am using have the right permission to make this action. My app has business_management permission (advanced access) and my user has an administrative role, which means I am able to invite the exact new user to the same business manager via facebook ui.

    new Business.APIRequestCreateBusinessUser("181431399044864",FacebookUtil.createApiContext(request.getAccessToken()))
            .setEmail("test@gmail.com")
            .setRole(BusinessUser.EnumRole.VALUE_EMPLOYEE)
            .execute();

It returns me the error message:

{ "error": { "message": "Application does not have permission for this action", "type": "OAuthException", "code": 10, "error_data": { "hash": null }, "error_subcode": 2859030, "is_transient": false, "error_user_title": "This Action Is Not Allowed", "error_user_msg": "Please retry this action in a few minutes", "fbtrace_id": "AsErZRmD617WCt9yYFZkUZR" } }

Meanwhile during my investigations I have figured out that I can make this action by using an admin system user access token instead of a simple user. But the issue here is that I can not generate an admin system user access token programmatically https://github.com/facebook/facebook-java-business-sdk/issues/438

Expected Results: