oauth - Getting user information when using OAuth2 - is the following reasonable? -
i creating api (restlet, gae) , implemented openid authentication , oauth2 protect access api. when testing client web app built, fine. when user hits part of web app wants access api, user asked login via openid , asked grant access web app grab resources api.
however, noticed web app doesn't know user (!). web app has auth token. thus, web app can't "hello, username", since doesn't know user is.
with restlet technology, authentication essentially: // authentication code openidverifier verifier = new openidverifier(openidverifier.provider_yahoo); verifier.addrequiredattribute(attributeexchange.email);
authenticator au = new myredirectauthenticator(getcontext(), verifier, null);
while following handles both authentication , oauth2 authorization: // authentication + oauth code: oauthparameters params = new oauthparameters("2345678901", "secret2", "http://localhost:8888/v3/", roles); oauthproxy local = new oauthproxy(params, getcontext());
initially using "authentication + oauth" in web app , authentication happening "invisibly" (as mentioned above).
i figured 1 way around "problem" if web app handles authentication "visibly". added authentication code web app. flow looks exact same user, web app able capture user info (email) , fine. there doesn't seem conflict "both" code either.
another way around problem add api return user info associated authtoken (a la twitter's verify_credentials).
my question: approach have taken reasonable? should use twitter approach instead? or different? (i pretty new stuff, hard figure out if choosing solution seems work, hit brick wall later on).
the short answer when client web app gets permission access oauth resources on behalf of user, client web app isn't supposed know user (login, password, etc.). if client web app wants know user is, can provide authentication.
i have implemented above scheme restlet , google app engine, allowing user authenticate resource server via openid , adding google authentication web client app (just can give "hello" message). seems fine.
Comments
Post a Comment