You can close the instance of the browser by calling the ref.close()
method where ref
is the reference to the current browser instance. You can further explore the InAppBrowser API here
. Note that a _self target will open a domain from the white-listed in the official browser, or in the InAppBrowser if the domain is not in the white-listed. More on whitelisting in Cordova you can read here
Most of the times you will subscribe to the 'loadstop' or 'loadstart' events of the browser and obtain the access token for the user from the response. When this is completed you can call the ref.close()
Furthermore, you may consider to implement a login process with a token-based authentication where the user exchanges here username and password for a token from an authentication API. Probably the API you are currently using has a REST endpoint for authentication and you can call it directly from your app. Needless to say that you should call the server over SSL/TLS. For further security you may consider to use the SSL certificate checker
plugin from the Telerik Verified Plugins Marketplace.
Let me know if you have further questions.