android - Google Cloud Endpoints and user's authentication -


i'm new appengine world, , wanting create backend using cloud endpoints mobile application i'm developing.

one of problem right user's authentication. i've been following udacity's mooc on app engine, , taught how authenticate user api request using google accounts. on backend side, have add user parameter our method, , check if user signed in. far know, user parameter generated app engine, based on authorization header of our request. (might need confirmation there)

now, there's bunch of stuff i'm not sure understand , weren't explained on mooc.

now, i'd know if compatible other oauth schemes, beside google? so, if want implement facebook authentication, pass facebook access token?

from searched, using facebook sdk on android lead me able generate user access token, identifies user to facebook. after sending backend, want check it's validity facebook, , if it's valid, create new user application. now, i'd want generate new token identify user to app. need do so?

you can supply own authenticator endpoints , injected user obtained authenticator https://developers.google.com/appengine/docs/java/endpoints/javadoc/com/google/api/server/spi/config/authenticator.html.

the facebook credentials can sent via header, e.g. authorization header , can accessed backend via httpservletrequest, can handle inside authenticator.authenticate method.

for example.

// custom authenticator class public class myauthenticator implements authenticator {   @override   public user authenticate(httpservletrequest request) {     string token = request.getheader("authorization");     if (token != null) {       string user = authenticatefacebook(token);  // apply facebook auth.       if (user != null) {         return new user(user);       }     }     return null;   } }  // endpoints class. @api(name = "example", authenticators = {myauthenticator.class}) public class myendpoints {   public container getthing(user user) {     container c = new container();     if (user != null) {       c.email = user.getemail();     }     return c;   }    public class container {     public string email;     public string extradata;   } } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -