Google will not allow you to perform direct authentication by directly processing user credentials. Instead, Google wants you to implement an authentication protocol, typically OAuth 2.0. Other popular authentication protocols you may hear about are OpenID 1.0, 2.0, OpenID Connect, SAML 2.0, ID-FF, etc. These protocols will redirect the user to the Identity Provider (in this case, Google) and send you an assertion that you can use to trust the user. Using APIs such as Google, you should use the OAuth authorization functionality, which provides you with a token that you can use with all Google APIs after authentication.
With PhoneGap and mobile apps, everything is a little different than the typical OAuth setup.
In your case, the browser is in a controlled environment, in your application, and you can
- select to redirect the user to the Google authorization endpoint using native mode,
- select to open ChildBrowser with the Google authorization endpoint so as not to lose any state in your application.
- to somehow open Safari or another browser with an authorization endpoint and register your own scheme handler to redirect the user back to your application after authentication.
These examples are vaguely mentioned in the OAuth 2.0 specifications, but there is no help on what is best or optimal in a particular use case. Often the best option is not ideal (from the point of view of the user).
I recently wrote a tutorial on how to make this work with Phonegap and ChildBrowser for iOS.
Andreas Γ
kre Solberg
source share