I actually follow the SessionLoginFragment.java example from facebook sdk samples.
What I really don't understand is:
when i do
session.openForRead(new Session.OpenRequest(fragment).setCallback(statusCallback));
to register my user on facebook and request a basic read permission (just check integration), it just doesn't work.
I dug up the debugger a bit and I went down the path. If you do not put requestCode in an OpenRequest session, it will give it random (and thatβs fine).
openForRead (my actual session is in CREATED state) will create a permission dialog. When you click the "Ok" button, it will execute
request.getStartActivityDelegate().startActivityForResult(intent, request.getRequestCode());
You can see the code from fb sdk source code. Well, requestCode is the same session (and good here).
When fb registers you with the system, it will complete its facebook.LoginActivity and call me back my onActivityResult in my activity. The problem is that here requestCode is different from the request. And I donβt know why and where it comes from!
If I log in to my fb account, my application will be there, so that means that I did the correct authentication flow, which ends well. But due to this problem, I will not be able to authenticate correctly from my application.
Do you know why and how I can solve it?
Thanks.
UPDATE WITH FLOW DETAILS:
This is the actual stream (from fragment ):
session.openForRead(new Session.OpenRequest(fragment).setCallback(statusCallback));
After creating it, the request code is (always) 64206 Now, the openForRead thread will call (the final part)
request.getStartActivityDelegate().startActivityForResult(intent, request.getRequestCode());
To do this, call the LoginActivity function from the SDK from facebook and perform a client / server / oauth check
Now my activity is called onActivityResult (not a fragment, but part of the activity)
and here I call
Session.getActiveSession().onActivityResult(activity, requestCode, resultCode, data);
And here requestCode is requestCode 129742
How is this possible? As I said, the problem in this whole thread is that the requestCode returned by onActivityResult is different from my requestCode request and this break (getActiveSession (). OnActivityResult returns without client code) the client part of the input.