I’m implementing oauth2 on an Ionic React app for Android but when receive the callback with the code and status, the webview shows an ERR_NAME_NOT_RESOLVED.
In the capacitor config.json I forze https for the app:
and in the strings.xml I use the custom_url_scheme <string name="custom_url_scheme">com.gronze.maps</string>
When calls to the mydomain/oauth2/authorize with the oauth params, my server sends the callback https://com.gronze.maps/?code=&state=m8882
but the app shows a blanck page with the ERR_NAME_NOT_RESOLVED.
But if I reload the webview with this url, the app works fine again.
What is happening? it fails on callback but works if reload
If instead of com.gronze.maps I use localhost, and the callback received is https://localhost/?code=&state=m8882 the page shows an ERR_CON_REFUSED and if I try to reload it works again
You are using the URL Scheme wrong. You’re specifying com.gronze.maps as your custom URL scheme, but then trying to load it with https as the scheme. It more likely should be com.gronze.maps://url?code=blah.
Long term though, you’d be better off using App/Universal links for this. Custom URL Schemes are quick and effective, but anyone can add whatever they want to their app, so if someone wanted to create an app to hijack calls into your application, they just register their application with the same scheme. We have documentation around using the better links here in the Capacitor Docs. Though to be clear, if you’re just testing, or this is a personal project, you’re probably okay using custom URL schemes.