May I ask you a question?
How to get Facebook access token to create with Facebook Android SDK 3.8 ?
I have tried various way to do it. But it seems like I don't do it the right way.
The app is Android 4.0 SDK and API Level 14.
In my UI I have a classical Android Button.
<Button
android:id="@+id/btn_facebook"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="80dp"
android:background="@drawable/button_facebook_normal"
android:text="@string/btn_facebook"
android:textColor="@color/white" />
In my AndroidManifest.xml
and this
<!-- FACEBOOK SDK -->
<activity android:name="com.facebook.LoginActivity" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/app_id" />
strings.xml
<string name="app_id">XXXXXXXX</string>
I just want to get the access token onClick of the button, then I can send it to the API application back end.
In my configuration the namespace is missing but I don't know where to put it in the facebook sdk configuration.
Thanks a lot in advance.
I try to get something out of this
https://developers.facebook.com/docs/facebook-login/access-tokens#usertokens
Ok my AppId was refering to an Application where I was not register as a developper so ... :) voila, the application was in a sandbox . right now I have the screen with "this application requiert your information"
The only thing missing right now is the Access Token which in a empty string at this time..
Here is the code
private String getAccessToken() {
Session.OpenRequest request = new Session.OpenRequest(this);
request.setPermissions(Arrays.asList("email", "user_birthday"));
request.setCallback(mCallback);
// get active session
Session mFacebookSession = Session.getActiveSession();
if (mFacebookSession == null || mFacebookSession.isClosed()) {
mFacebookSession = new Session(this);
}
mFacebookSession.openForRead(request);
return mFacebookSession.getAccessToken(); // the access token is empty here
}
StatusCallback mCallback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state,
Exception exception) {
// TODO Auto-generated method stub
System.out.println("test : "+session.getAccessToken());// the access token is empty here too.
}
}; // the code you already have