facebook / facebook-java-business-sdk

Java SDK for Meta Marketing APIs

Home Page:https://developers.facebook.com/docs/business-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting "Two factor authentication required" when generating an admin user system access token.

Denalda-lab opened this issue · comments

Which SDK version are you using?

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

What's the issue?

I am trying to generate an access token for admin user system with id 100034358611019. Instead of returning the access token I get an error response related with 2FA:

{
"error": {
"message": "Two factor authentication required. User have to enter a code from SMS or TOTP code generator to pass 2fac. This could happen when accessing a 2fac-protected asset like a page that is owned by a 2fac-protected business manager.",
"type": "OAuthException",
"code": 415,
"error_data": {
"hash": "8874359819718335175"
},
"error_subcode": 2859009,
"is_transient": false,
"error_user_title": "Two-factor authentication required",
"error_user_msg": "To continue working in your account, please refresh this page to authenticate. Or navigate to the business settings page and authenticate when prompted.",
"fbtrace_id": "AwfkZm6RouSgmnWYNFln2q1"
}
}

Meanwhile my user has enabled the 2FA.

Steps/Sample code to reproduce the issue

new User.APIRequestCreateAccessToken("100034358611019", FacebookUtil.createApiContext(request.getAccessToken())).setBusinessApp("2990249911190581").setScope("business_management").execute();

Expected Results:

  • I expect to get the generated access token.

close this as a duplicate of #438