OAuth, ERR_CONNECTION_REFUSED error

I’m trying to determine whether it’s an obvious bug or something more. I am trying to set up OAuth using Satellizer, it works in the browser but on Android I get an Application Error.

net::ERR_CONNECTION_REFUSED(http://localhost:8100…) I’m thinking it could be a few things, my API back end is running on a local machine, it’s broadcasting to a LAN address. I can connect to it in the android browser but maybe it’s an issue with my back end refusing connection? CORs is enabled so I checked that. It could be something to do with Ionic and passing the wrong port? I’m experienced with Angular but really new to Ionic/Cordova. I’ve followed a few different OAuth tuts and none of them seem to mention this error and my Google fu has been no help.

The process is thus, tap opens oauth window, accept permissions, this is where the browser diverges from the app, in the browser the window closes, the app sends out a request for auth to the back end and the user is logged in. In the app on the device it closes and immediately gives me the connection refused error.

Either help with the issue or help pointing me in the right direction would be really truly appreciated.

EDIT:

I tested the local auth and it connects to the back end fine, so it has to be related to the redirect window. Is it an issue of using the wrong origin?

3 Likes

Any updates here? I’m about to try out Satellizer and wondering what your status is on this.

No update as of yet, I put it on the back burner hoping someone might have some guidance. If I fix the issue I’ll be sure to post my solution.

I just finished integrating w/ Satellizer. email login is working fine (of course no new browser windows for that), and Facebook works fine in the browser. But when I emulate iOS the Facebook login craps out after I login w/ Facebook. I’ll post here when I figure it out.

Yeah, you’re in the same boat as me.

I’ll post as well if I figure it out.

I’m tied up w/ other things but from this and other things I’ve read I thought maybe I needed the inapp browser. Gave it a quick try and didn’t seem to fix the problem.

I know there was a blog post about how popular oauth login was for Ionic but I haven’t seen any actual working solutions yet that don’t require signing up for a third party service.

One of the more well known production apps HabitRPG requires you too do a weird hack manually to make it work.

Hey I am currently trying to get Satellizer working with ionic with basic email login. Any change you have an example of this code anywhere? Thanks :smile:

Did you get to work with Ionic/Cordova with Satellizer ?

I’m having the same problem when I get redirected by Instagram API. Works fine on browser, but in Android it gives me this same error for localhost. Any tips?

Those having problem can you try to use http://localhost/callback as fb callback with
cordova plugin add org.apache.cordova.inappbrowser in app browser with location=no

I also got the message net::ERR_CONNECTION_REFUSED(http://localhost/?code=...) when I tried to login facebook in my ionic + satellizer mobile app. Eventually I realized I should set $authProvider.platform = 'mobile' and it worked.

I also got the problem…
Here is my satellizer configuration

.config ($authProvider) ->

  commonConfig =
    popupOptions:
      location: 'no'
      toolbar: 'no'
      width: window.screen.width
      height: window.screen.height

  $authProvider.authHeader = 'satellizer'
  $authProvider.authToken = null
  $authProvider.baseUrl = null

  host = '@@SERVER_URL'

  if ionic?.Platform?.isIOS() or ionic?.Platform?.isAndroid()
    $authProvider.cordova = true
    $authProvider.platform = 'mobile'
    commonConfig.redirectUri = 'http://localhost/'

  $authProvider.facebook angular.extend {}, commonConfig,
    clientId: '@@FACEBOOK_CLIENT_ID'
    url: host + '/api/accounts/facebook'
    scope: ['email']
    scopeDelimiter: ','
    requiredUrlParams: ['display']

  $authProvider.google angular.extend {}, commonConfig,
    clientId: '@@GOOGLE_CLIENT_ID'
    url: host + '/api/accounts/google'

I also have installed in-app-browser plugin installed and it doesn’t work…

This problem was due to the cordova inAppBrowser plugin. Update your plugin to v1.2.1. and hopefully it should solve your problem.