:
firebaseからログインfacebook accessTokenを取得するには非常に簡単です。 firebase auth UIを使用していました。 facebookで認証した後、表示名、電子メール、プロバイダの詳細などfirebaseユーザオブジェクトから基本情報を取得します。しかし、あなたが性別のようなより多くの情報を望むなら、誕生日のfacebook Graph APIが解決策です。ユーザーがFacebookで認証されると、このようなアクセストークンを得ることができます。
AccessToken.getCurrentAccessToken()
ただし、有効なアクセストークンではなくNULL値が表示されることがあります。その前にfacebook SDKを初期化しておいてください。 Googleにとって
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(this);
}
} After initialization use graphAPI
if(AccessToken.getCurrentAccessToken()!=null) {
System.out.println(AccessToken.getCurrentAccessToken().getToken());
GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
// Application code
try {
String email = object.getString("email");
String gender = object.getString("gender");
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender,birthday");
request.setParameters(parameters);
request.executeAsync();
}
else
{
System.out.println("Access Token NULL");
}
:
Jittyが掲載Facebookの利用方法については、あなたの活動
private static final int RC_SIGN_IN = 8888;
public void loadGoogleUserDetails() {
try {
// Configure sign-in to request the user's ID, email address, and basic profile. ID and
// basic profile are included in DEFAULT_SIGN_IN.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
// Build a GoogleApiClient with access to GoogleSignIn.API and the options above.
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
System.out.println("onConnectionFailed");
}
})
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from
// GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
// Get account information
String PhotoUrl = acct.getPhotoUrl().toString();
}
}
}
で。しかし、Googleではこの方法を使用しています:http://stackoverflow.com/questions/42406660/how-to-get-gender-and-birthday-from-google-provider-using-firebaseauth/42456960#42456960 – Sabeeh