All PhoneGap 3.5 oAuth Fempt errors (iOS)

I am trying to perform oAuth authentication in a PhoneGap app for iOS. I ran into the following problem. I primarily tested this for Google oAuth, but tried LinkedIn also with similar results:

  • I can launch InAppBrowser, log in to my Google account and allow the application access to my account.
  • InAppBrowser successfully returns an access token, expires, etc. When the application tries to send the access token back, I get the following error in Xcode:

webView: didFailLoadWithError - -1004: Failed to connect to the server.

This happens when I run the application on either an iOS simulator or actually an iPhone.

What I tried:

  • I tried several different code samples, including what oauth.io provides as a code sample for their maintenance.
  • Install Xcode on a separate computer and try there.
  • Trying an old version of Phonegap

Interestingly, this happens when I have a "redirect URI":

http://localhost 

.. as defined by the Google APIs Console, and all the OAuth implementation tutorials that I went through. Obviously, the InAppBrowser code should stop the page loading and capture the data that is added to the URL bar. If I change the redirection to another value that the Google console provides (urn: ietf: wg: oauth: 2.0: oob), it redirects to the actual page with instructions for copying and pasting the code from the input into my URL string. Which does not help me in the context of InAppBrowser.

I am at a loss what to try next. Any suggestions?

+6
source share
1 answer

Have you tried using OAuth tools like OAuth.io ?

There is a Phonegap / Cordova SDK that allows you to use OAuth to make API calls with much less pain.

Once you have created an account, you can find guides for the Phonegap SDK:

And the docs here:

And step by step the tutorial about a typical project is:

OAuth.io is a Saas solution. If you're more interested in an open source solution, you can check out oauthd , the open source kernel.

Hope that helps :)

+5
source

Source: https://habr.com/ru/post/972931/


All Articles