问题描述:

I have integrated google signin in my app. The sign in is perfectly working with webview. But when I run the app on device,the google app is opening and after signed in no data is getting fetched. So my question is, how to solve this error or how to stop opening the google app when I click on signin button.

Note : I don't want to uninstall g+ app.

网友答案:

Well, you can simply throw away Google+ Sign In SDK and work with the API manually.

In simple steps:

  • Open Google+ Auth URL (like https://accounts.google.com/o/oauth2/auth plus attributes) in Safari / Webview / Safari View Controller
  • process callback on provided callback URL with response data via -application:openURL:sourceApplication:annotation: in your App delegate
  • parse Auth code (as code attribute) from this URL
  • call Google Auth API again by posting this code (URL like https://accounts.google.com/o/oauth2/token) to obtain Auth token
  • use this token for authentication the way you do right now

I realised this flow by reverse-engineering the Google+ library after seeing Google+ library to heavyweight and not effective especially because of some issues with it. You can additionally handle Google+ app this way as well, it's just differs in the initial URL you open.

相关阅读:
Top