IBM Worklight - How to use Google authentication i

2019-03-04 02:49发布

问题:

I am facing difficulties implementing social authentication (using Google, Facebook) in a Worklight app with the Android and iOS environments.

I am trying to use oauth. The following are requirements:

var OAUTHURL    =   'https://accounts.google.com/o/oauth2/auth?';
var VALIDURL    =   'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=';
var SCOPE       =   'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email';
var CLIENTID    =   '97612631714.apps.googleusercontent.com';
var REDIRECT    =   ??????
var LOGOUT      =   'http://accounts.google.com/Logout';

After authentication it should be redirected to our app (is located in public domain). For that we have to add a redirect uri to Google API.

I don't know what should be put in REDIRECT.

回答1:

The normal cycle will not work in a Hybrid application because your app does not have a public URL.

Here is one person who documented his experience doing something similar: http://www.itsalif.info/content/oauth-google-api-gapi-phonegap-childbrowser-jquery

Also: https://github.com/andreassolberg/jso/blob/master/README-Phonegap.md

Also a twitter/android example: http://www.mobiledevelopersolutions.com/home/start/twominutetutorials/tmt5p1