How to prevent Facebook login authentication from the official app with Android app

Asked 2 years ago, Updated 2 years ago, 82 views

I have created an app for Android 4.0.
Among them, I would like to authenticate (OAuth) on Facebook.

Available on FacebookSDK
I tried using Session, UserSettingsFragment and LoginButton in GUI components.
If you have a Facebook app on your device,
You will automatically try to authenticate with the Facebook app.

Whether you have a Facebook app or not
I'd like to do the same thing, but if anyone knows how to do it, please let me.
Or please let me know if there is a way to authenticate OAuth without using the official app.

android facebook

2022-09-30 11:53

4 Answers

Why do you want it to work the same way whether you have a Facebook app or not?

As @tokoi wrote, if you use WebView to write the code to handle OAuth on the server side and use it via WebView, it may not be impossible to implement it, but in this case, the experience of requesting a username/password again on WebView is concerned.

Also, if you look at Facebook's terms and conditions (https://developers.facebook.com/policy/Japanese/), you can see that at 7.2

Native iOS and Android apps that implement Facebook login must use the official login SDK.

Therefore, I don't think it's a good idea to avoid the flow defined in SDK from a convention perspective.


2022-09-30 11:53

Previously, to avoid bugs that only occur on certain devices, we have taken such actions... but the source is too different from that time, so I can't give you a direct answer, sorry.

https://github.com/facebook/facebook-android-sdk
The SDK source code has been disclosed in , so you should be able to do so by removing the operation of the official app (package name com.facebook.katana).

I grep the source code, but I haven't tried it yet. com/facebook/internal/NativeProtocol.java
Wouldn't it be possible to use the buildFacebookAppList method in to return an empty list (although other operations as well as authentication are likely to be accompanied)?


2022-09-30 11:53

How about using the official app to log in?
As a procedure, I think it would be good to do the following.

If the Facebook app is not installed, notify the user that the installation is required, transition to the Facebook app page in GooglePlay, and close the app

Uriuri=Uri.parse("market://details?id=com.facebook.katana");
Intent=new Intent(Intent.ACTION_VIEW,uri);
startActivity (intent);
finish();


2022-09-30 11:53

It's quite tricky and has a low chance of winning, but there's another way I can try it.

I'll write it for your reference just in case:
I considered getting a token from WebView that might be stored in a cookie value or a Javascript variable value and giving it to FacebookAndroidSDK to hijack the session, but I decided that it would be impossible to share the token with the Javascript and Android apps because they are managed by app.


2022-09-30 11:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.