Android Facebook Log In with AWS Cognito -


i'm having trouble authenticating users facebook , creating single new identity aws cognito. if user deletes app , re-downloads want cognito return same identity.

facebook login works credentialsprovider.setlogins(logins); creates 4 new unauthenticated identities every time.

    final cognitocachingcredentialsprovider credentialsprovider = new cognitocachingcredentialsprovider(getapplicationcontext(), "xxxxxxxx", regions.us_east_1);      loginbutton = (loginbutton) findviewbyid(r.id.login_button);     loginbutton.setreadpermissions(arrays.aslist("email", "user_friends"));      callbackmanager = callbackmanager.factory.create();      accesstokentracker = new accesstokentracker() {         @override         protected void oncurrentaccesstokenchanged(                 accesstoken oldaccesstoken,                 accesstoken currentaccesstoken) {             updatewithtoken(currentaccesstoken);          }     };      loginbutton.registercallback(callbackmanager, new facebookcallback<loginresult>() {         @override         public void onsuccess(loginresult loginresult) {              map<string, string> logins = new hashmap<string, string>();             logins.put("graph.facebook.com", accesstoken.getcurrentaccesstoken().gettoken());             credentialsprovider.setlogins(logins);             log.d("logtag", "my id " + logins);         }           @override         public void oncancel() {             toast.maketext(getbasecontext(), "login cancelled", toast.length_short).show();             log.v("loginactivity", "cancel");         }          @override         public void onerror(facebookexception exception) {             toast.maketext(getbasecontext(), "problem connecting facebook", toast.length_short).show();             log.v("loginactivity", exception.getcause().tostring());         }     });  }  private void updatewithtoken(accesstoken token) {     if (token != null) {          intent intent = new intent(login.this, navdrawer.class);         login.this.startactivity(intent);      }     ; }  @override public void ondestroy() {     super.ondestroy();     accesstokentracker.stoptracking(); }  @override protected void onresumefragments() {     super.onresumefragments();     updatewithtoken(accesstoken.getcurrentaccesstoken()); }  @override protected void onactivityresult(int requestcode, int resultcode, intent data) {     super.onactivityresult(requestcode, resultcode, data);     callbackmanager.onactivityresult(requestcode, resultcode, data);     intent intent = new intent(login.this, buffer.class);     login.this.startactivity(intent); } 

}

any amazing, you!

i can see starting new activity every time access token facebook updated. mean creating different instances of cognitocachingcredentialsprovider every time, not right.

ideally should have cognitocachingcredentialsprovider singleton in application , use in activities , app logic. can use cognito sample application example model flow.


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -