Facebook API: cannot login on Android

  • Replies:2
  • Answered
Alexander Shmuratko
  • Forum posts: 2

Sep 11, 2013, 10:22:05 AM via Website

I'm trying to implement Facebook login on Android, using the Facebook API. I've done everything the way "Facebook Login Flow for Android" says (sorry, I'm a new user and cannot post links). My code is below.

1public class FBSignIn extends Fragment {
2 @Override
3 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
4
5 final View v = super.onCreateView(inflater, container, savedInstanceState);
6 setTitle("Sign In");
7 reloadTemplate();
8 return v;
9 }
10
11 @Override
12 public boolean executeCommand(BaseWebView webView, String command, String data) {
13
14 if (command.equalsIgnoreCase("login")) {
15 Session session = Session.getActiveSession();
16
17 if (session != null && session.isOpened()) {
18 loginWithFBToken(session.getAccessToken());
19 return;
20 }
21
22 Session.openActiveSession(getActivity(), true, callback);
23 }
24
25 return true;
26 }
27
28 private Session.StatusCallback callback = new Session.StatusCallback() {
29
30 @Override
31 public void call(Session session, SessionState state, Exception exception) {
32 onSessionStateChange(session, state, exception);
33 }
34 };
35
36 private void onSessionStateChange(Session session, SessionState state, Exception exception) {
37 if (state.isOpened()) {
38 // Facebook logged in...
39
40 } else if (state.isClosed()) {
41 //Facebook logged out...
42 }
43 }
44
45}

In my main activity I've supplied the overriden method:
1@Override
2 public void onActivityResult(int requestCode, int resultCode, Intent data) {
3 super.onActivityResult(requestCode, resultCode, data);
4 Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
5 }

After the Session.openActiveSession() call, on the 1st entrance to onSessionsStateChange() function, I have
1state == OPENING, exception == null.

On the 2nd entrance to this function, I have
1state == CLOSED_LOGIN_FAILED, exception == Invalid access token.

What does that mean?

Reply
Alexander Shmuratko
  • Forum posts: 2

Sep 12, 2013, 3:17:15 PM via Website

My mistake. The reason was the incorrect (or sth wrong with) application id (specified in AndroidManifest.xml).

Reply
sarah Edwards
  • Forum posts: 2

Jan 7, 2015, 11:07:28 AM via App

Alexander Shmuratko

My mistake. The reason was the incorrect (or sth wrong with) application id (specified in AndroidManifest.XML).

I for got my login password can you get it

Reply