:
이 중포 기지에서 페이스 북 accessToken을 얻으려면 아주 간단합니다. firebase auth UI를 사용하고있었습니다. 페이 스북 (Facebook) 인증 후 표시 이름, 이메일, 공급자 정보와 같은 firebase 사용자 객체의 기본 정보를 얻습니다. 그러나 성별과 같은 더 많은 정보를 원한다면, 생일 페이스 북 그래프 API가 해결책입니다. 일단 페이스 북으로 사용자 인증을하면 이와 같은 액세스 토큰을 얻을 수 있습니다.
AccessToken.getCurrentAccessToken()
하지만 가끔은 당신에게 NULL 값 대신에 유효한 액세스 토큰을 제공 할 것입니다. 그 전에 페이스 북 SDK를 초기화했는지 확인하십시오. 구글
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 게시 페이스 북의 사용 방법에 대한 활동
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();
}
}
}
합니다. 하지만 구글은이 방법을 사용합니다 : http://stackoverflow.com/questions/42406660/how-to-get-gender-and-birthday-from-google-provider-using-firebaseauth/42456960#42456960 – Sabeeh