I am using the cordova in-app-browser plugin to oauth into salesforce. This used to work fine for both android and iOS but it seems to be broken now that I have updated capacitor and android to API 31 I am getting a variety of errors depending on my configuration. The original error was net::ERR_CLEARTEXT_NOT_PERMITTED
Which was solved by adding cleartext: true to my capacitor.config.ts file. But now I am getting ERR_CONNECTION_REFUSED.
It looks like you’re running both the Android emulator and your API on the same network, correct? Android emulator’s localhost is the emulator’slocalhost, not your computer. This is unlike the iOS simulator where localhost on the sim is localhost for your computer.
In your Capacitor code, to reach your local API, try replacing http://localhost/callback with http://10.0.2.2/callback. On the default Android emulator, 10.0.2.2 will forward requests to your computer’s localhost.
No, I am not running it on the same network. The way it works is there is a login website that is opened in in app browser. This is not being run locally, it is on the Salesforce.com platform. When the user enters their credentials within salesforce, the in app browser parses out the token and then they are authenticated in the app. But the callback here does not open. In the past, I had used the cordova whitelist plugin.
What is the URL for the ERR_CONNECTION_REFUSED? Is it for force.com or for 127.0.0.1? The Salesforce URL is using https which wouldn’t have triggered the ERR_CLEARTEXT_NOT_PERMITTED error; which led me to believe that your error was happening during callback, due to the localhost issue. My mistake!