facebook-ios-sdk icon indicating copy to clipboard operation
facebook-ios-sdk copied to clipboard

Unable to get token_for_business in case user opts out of ATT

Open taozhang159 opened this issue 1 year ago • 11 comments

Checklist before submitting a bug report

Xcode version

15.3

Facebook iOS SDK version

17.0.1

Dependency Manager

CocoaPods

SDK Framework

Login

Goals

Using Facebook that limit login, when I reject the ATT pop-up window for ad tracking, I hope to get the token_for_business corresponding to the user.

Expected results

Using Facebook that limit login, when I reject the ATT pop-up window for ad tracking, I hope to get the token_for_business corresponding to the user.

Actual results

Version:

Upgrade Facebook version to 17.0.1

Scenes:

  1. Traditional login mode,

1.1 Start the application, select the Deny Authorization ATT pop-up window, click Facebook to log in, you will enter the limited.facebook.com website, obtain the accessToken, and then request https://graph.facebook.com/v19.0/xx?access_token=xx&fields =token_for_business

{ "error": { "message": "Invalid OAuth access token - Cannot parse access token", "type": "OAuthException", "code": 190, "fbtrace_id": "A3YYkEZkifmBsHd3qLtZ9ER" } }

  1. Restrict login mode

2.1 Start the application, select the Deny Authorization ATT pop-up window, click Facebook to log in, you will enter the limited.facebook.com website, and the accessToken obtained is nil. Another OIDC-Token has a value, but token_for_business cannot be obtained through OIDC.

in conclusion:

I want to know how to correctly obtain token_for_business after rejecting the ATT pop-up window.

Steps to reproduce

No response

Code samples & details

// Traditional login code

[self.fbloginMangager logInWithPermissions: [self getFacebookPermissions] fromViewController:nil handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
    if (error) {

    }else if (result.isCancelled) {

    }else {
        NSString *accessToken = result.token.tokenString? : @"";
    }
 }];



// limit login code

FBSDKLoginConfiguration *configuration =
  [[FBSDKLoginConfiguration alloc] initWithPermissions:@[@"public_profile"]
                                              tracking:FBSDKLoginTrackingLimited
                                                 nonce:@"123"];
[self.fbloginMangager logInFromViewController:nil configuration:configuration completion:^(FBSDKLoginManagerLoginResult * _Nullable result, NSError * _Nullable error) {
    if (error) {

    }else if (result.isCancelled) {

    }else {
        NSString *accessToken = result.token.tokenString;
        NSString *jwtToken =
        FBSDKAuthenticationToken.currentAuthenticationToken.tokenString? : @""
    }
}];

taozhang159 avatar May 14 '24 14:05 taozhang159

Face the same issue, anyone has any idea? In the limit login, how can we get the token_for_business, since we use this field as a unique identifier for the user regist from Facebook.

penoty avatar May 15 '24 07:05 penoty

Same here. Does anyone know if it's still possible to obtain the token_for_business in this situation?

shixueqian avatar May 20 '24 08:05 shixueqian

Hello, that is explained in the documentation, but quite hard to find. So you need to obtain an App Access Token and use it on your server to fetch token_for_business from the GraphQL.

image

vladyslav-androshchuk avatar May 21 '24 09:05 vladyslav-androshchuk

When you reject the pop-up authorization of advertising ATT, the access_token obtained cannot be obtained through the method in the above document for token_for_business

taozhang159 avatar May 21 '24 11:05 taozhang159

When you reject the pop-up authorization of advertising ATT, the access_token obtained cannot be obtained through the method in the above document for token_for_business

access_token - yes, but read more carrefully, I said about App Access Token which you obtain totaly different and only on the backend (due to the security):

image

vladyslav-androshchuk avatar May 21 '24 11:05 vladyslav-androshchuk

当你拒绝广告ATT弹窗授权时,获取到的access_token无法通过上述文档中token_for_business的方法获取

access_token-是的,但请仔细阅读,我说过App Access Token您的获得是完全不同的,并且只告知(安全性考虑):

图像

Our Facebook login uses token_for_business as the user's unique identifier, but after upgrading Facebook to 17.0.2, when using restricted login, after rejecting ATT, we cannot get token_for_business through the GET /ASID?fields=token_for_business interface. Is there any good way? Can you give me some advice?

taozhang159 avatar Jul 03 '24 10:07 taozhang159

Same issue. Maybe Facebook doesn’t want to resolve this issue

dovantien2911 avatar Jul 23 '24 09:07 dovantien2911

Same issue. Maybe Facebook doesn’t want to resolve this issue

https://graph.facebook.com/{ASID}?fields=token_for_business&access_token={APP_TOKEN}

M7TSuki avatar Aug 09 '24 02:08 M7TSuki

Same issue. Maybe Facebook doesn’t want to resolve this issue

https://graph.facebook.com/{ASID}?fields=token_for_business&access_token={APP_TOKEN}

In IOS (SDK 17) can't get "APP_TOKEN" after login

dovantien2911 avatar Aug 09 '24 04:08 dovantien2911

First of all, you should get the app access token , Please note that this is not the access_token obtained when logging into Facebook through the app, but rather the app access token generated by the backend via the Graph API.
I solved this issue with the step:

  1. Generating an App Access Token https://developers.facebook.com/docs/facebook-login/guides/access-tokens/#apptokens
  2. obtained the userId when logging into Facebook through the app and the app access token obtained by requesting the Graph API. the documentation example: https://graph.facebook.com/{user id}?fields=token_for_business&access_token={app access token}

then you can get the token_for_business, I hope this helps you.

akzhang avatar Aug 16 '24 06:08 akzhang

thank you!

-‘嗚啦唿、 @.***

 

------------------ 原始邮件 ------------------ 发件人: "facebook/facebook-ios-sdk" @.>; 发送时间: 2024年8月16日(星期五) 下午2:33 @.>; @.@.>; 主题: Re: [facebook/facebook-ios-sdk] Unable to get token_for_business in case user opts out of ATT (Issue #2421)

First of all, you should get the app access token , Please note that this is not the access_token obtained when logging into Facebook through the app, but rather the app access token generated by the backend via the Graph API. I solved this issue with the step:

Generating an App Access Token https://developers.facebook.com/docs/facebook-login/guides/access-tokens/#apptokens

obtained the userId when logging into Facebook through the app and the app access token obtained by requesting the Graph API. the documentation https://graph.facebook.com/{user id}?fields=token_for_business&access_token={app access token}

then you can get the token_for_business, I hope this helps you.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

M7TSuki avatar Aug 27 '24 07:08 M7TSuki