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.
Here is my capacitor.config.ts:
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
appId: 'org.myapp.app',
appName: 'MyApp',
webDir: 'www',
bundledWebRuntime: false,
server: {
// url: 'http://localhost',
cleartext: true,
hostname: '127.0.0.1'
}
};
export default config;
Here is my ionic info:
Ionic:
Ionic CLI : 6.19.0 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 6.0.9
@angular-devkit/build-angular : 13.0.4
@angular-devkit/schematics : 13.0.4
@angular/cli : 13.0.4
@ionic/angular-toolkit : 5.0.3
Capacitor:
Capacitor CLI : 3.4.1
@capacitor/android : 3.4.3
@capacitor/core : 3.4.1
@capacitor/ios : 3.4.1
Utility:
cordova-res : 0.15.4
native-run : 1.5.0
System:
NodeJS : v16.13.2 (/usr/local/bin/node)
npm : 8.1.2
OS : macOS Monterey
And finally the code that creates the browser:
const clientId = this.myDataService.getAppId();
const redirectUri = 'http://localhost/callback';
const loginUrl = 'https://mysforg.force.com/services/oauth2/authorize?display=touch' +
'&response_type=token&client_id=' + clientId +
'&redirect_uri=' + redirectUri;
console.log('### loading login url: ' + loginUrl);
const options = 'location=no,toolbarposition=top,enableViewportScale=yes,closebuttoncaption=Cancel,' +
'clearsessioncache=yes,clearcache=yes';
console.log('### loginUrl: ' + loginUrl);
const browser = this.iab.create(loginUrl, '_blank', options);
console.log('### loaded');
browser.on('loadstart').subscribe(
(event) => {
console.log('### got uri: ' + redirectUri);
// if(event.url.substr(0, redirectUri.length) === redirectUri) {
// this.handleLoginEvent(event.url, browser);
// }
}, err => {
console.log('### got an error: ', err);
}
);
1 post - 1 participant