Comments (13)
Tried something...added this to OAuth2ClientPlugin.java
@Override
protected void handleOnNewIntent(Intent intent) {
Log.e(getLogTag(), "intent data: "+ intent.getDataString());
}
04-15 21:16:43.899 19959 19959 E Capacitor/Plugin/OAuth2ClientPlugin: intent data: 2000 0
04-15 21:16:43.912 19959 19959 D Capacitor: Sending plugin error: {"save":false,"callbackId":"60725044","pluginId":"OAuth2Client","methodName":"authenticate","success":false,"error":{"message":"ERR_GENERAL; NULL INTENT DATA"}}
-- this is from a log line I put into handleOnActivityResult
04-15 21:16:43.915 19959 19959 E Capacitor/Plugin/OAuth2ClientPlugin: intent data: com.domain.myapp://oauth#access_token=&token_type=bearer&expires_in=3600&scope=https://graph.microsoft.com/.default%20https://graph.microsoft.com/Mail.Read%20https://graph.microsoft.com/User.Read&state=zlANnwD7pBD9komlE3Uw
--- this is from a log line in handleOnNewIntent
04-15 21:16:43.916 19959 19959 V Capacitor/Plugin/App: Notifying listeners for event appUrlOpen
04-15 21:16:43.916 19959 19959 D Capacitor/Plugin/App: No listeners found for event appUrlOpen
Note that the NewIntentHandler does fire when the app starts, but of course the scheme won't match unless the intent matches that from the OAuth2 redirect.
from capacitor-oauth2.
I had the same issue when the intent URL was the same as the appAuthRedirectScheme
.
Below is how I made the error go away, but maybe the documentation should be updated?
build.gradle:
manifestPlaceholders = [
'appAuthRedirectScheme': 'com.testapp.ionic'
]
Strings.xml:
<string name="custom_url_scheme">com.testapp.ionic.intent</string>
(I added .intent
suffix to the app, but could be any text, as long as it differs from the other)
from capacitor-oauth2.
Thanks for the response,
Unfortunatly i haven't got this to work yet.
In android/app/build.gradle I made sure to set the following:
manifestPlaceholders = [ 'appAuthRedirectScheme': 'com.company.mobiletest' ]
This matches the file structure in android/app/...../java
And in the strings.xml slightly different:
<string name="custom_url_scheme">com.company.mobiletestapp</string>
I need the last one to be com.company.mobiletestapp, because the uri registered with the Oauth server is com.company.mobiletestapp://oauth, and if i understand correctly this is what fill in in
android: {
customScheme: 'com.company.mobiletestapp://oauth'
},
what am I doing wrong, im using the responseType: 'token', expecting the token to be returned in something like 'com.company.mobiletestapp://oauth#access_token=XXX'
from capacitor-oauth2.
Also suffering with this one - trying to get it to work, and I can see the following in the phone log:
5 16:52:35.731 27554 27587 D GeckoViewNavigation[C]: loadURI: uri=xxx.yyyy.myapp://oauth#access_token=EwBwA8J%3d%3d&token_type=bearer&expires_in=3600&scope=https://graph.microsoft.com/.default%20https://graph.microsoft.com/Mail.Read%20https://graph.microsoft.com/User.Read&state=mfvymhWXGXLLgtdvZiQz where=1 flags=0x800000 tp=null
So I can see that the phone is attempting to open a URI, and the handleOnActivityResult routine is being called in OAuth2ClientPlugin.java
I put a logging line in there, and it logs that requestCode=2000, resultCode=0 and data=null.
I tried various ways at getting the URI, but haven't succeeded yet - hopefully you might be able to give me some pointers.
Interestingly, the next few capacitor log lines are:
04-15 16:52:35.899 26698 26698 D Capacitor: Sending plugin error: {"save":false,"callbackId":"103362721","pluginId":"OAuth2Client","methodName":"authenticate","success":false,"error":{"message":"ERR_GENERAL; NULL INTENT DATA"}}
my error
04-15 16:52:35.910 26698 26698 V Capacitor/Plugin/App: Notifying listeners for event appUrlOpen
04-15 16:52:35.910 26698 26698 D Capacitor/Plugin/App: No listeners found for event appUrlOpen
...
04-15 16:52:35.994 26698 26698 D Capacitor: App restarted
04-15 16:52:36.012 26698 26698 D Capacitor: App started
...
04-15 16:52:36.015 26698 26698 D Capacitor/Plugin/App: Firing change: true
04-15 16:52:36.015 26698 26698 V Capacitor/Plugin/App: Notifying listeners for event appStateChange
04-15 16:52:36.016 26698 26698 D Capacitor/Plugin/App: No listeners found for event appStateChange
04-15 16:52:36.033 26698 26698 D Capacitor: App resumed
from capacitor-oauth2.
I'm about to look into this as I'm currently working on the 2.0.0 release but I need your version information and config of the plugin.
### Capacitor version:
<!-- Provide the version of Capacitor and related installed dependencies.
You can use `npx cap doctor` for the output from the root directory of your project. -->
Run `npx cap doctor`:
Replace this with the commands output
### Library version:
<!-- Please remove all items that are not relevant. -->
- 2.0.0
- 1.1.0
- 1.0.1
- 1.0.0
- other: (Please fill in the version you are using.)
### OAuth Provider:
<!-- Please remove all items that are not relevant. -->
- Google
- Facebook
- Azure AD
- Azure App Registration
- Github
- Other: (Please fill in the provider you are using.)
### Your Plugin Configuration
<!-- Without secret stuff (of course). -->
{
// Replace this with your plugin configuration
}
Please create a new comment with your filled in data.
from capacitor-oauth2.
A note at "Your Plugin Configuration": Plz mask your secret stuff and do not remove the parameter because I need to see which config parameters you're using.
from capacitor-oauth2.
from capacitor-oauth2.
Hi Steve,
As your using Capacitor 2.x you will have to wait for 2.0.0 of this plugin because on iOS you will most probably run into a problem with XCode 11.4. See #74 for details.
I'm working on better docs in a feature branch. Plz check if your Android configuration is valid.
Regardless of that v1.1.0 is not intended to work with Capactior 2.x only v2.0.0 will.
BR, Michael
from capacitor-oauth2.
@steve-allam Thx for the Plugin#handleOnNewIntent(Intent intent)
hint. I'll look into it.
from capacitor-oauth2.
@steve-allam Could you describe the steps on your phone until the error occurs. eg.
- Launch Capacitor App
- Tab login button
- Chrome (tab) launches but Capacitor App lives on in the background
- Enter credentials
- Chrome closes
- Capacitor App is switched to the foreground
- Intent is always null. Crash!
Which Android versions and devices do you test on?
I can only think of a situation when the Android system or the user closes the Capacitor App after Chrome is launched.
I also look into handleOnNewIntent
but afaik it is only called from the BridgeActivity#load
According to the Capacitor Docs the way I handle the result of a activity should be fine. Android itself proposes the use of new AndroidX features to handle the result but that's not supported by Capacitor right now. (Plugin, Bridge)
I'll try changing the plugin's request code to sth more unique. Maybe another plugin uses the same but that should not be a problem because both plugins would get the intent.
from capacitor-oauth2.
from capacitor-oauth2.
Hey Steve,
thx for the detailed response.
I will most likely support both cases and introduce a Android option to switch it on/off.
The default settings will depend on the outcome of my tests. If the OnNewIntent
approach works the same way for my use case it the default.
BR, Michael
from capacitor-oauth2.
I tested with API Level 29, 28, 27 in Simulator and 26 on a real device and handleAuthorizationRequestActivity
was always called. Only on application startup the onNewIntent
method was called but naturally without any OAuth information.
The app will not crash any more and I introduced a new Android config parameter handleResultOnNewIntent
so you can switch on the alternative handling but it will be off on default.
from capacitor-oauth2.
Related Issues (20)
- Problem opening native authenticator app HOT 1
- How to get Refresh Token with windowTarget: "_self". HOT 3
- Call back function is not returning the value
- ERR_STATES_NOT_MATCH
- HELP: Getting "USER_CANCELLED" error with Google oAuth2 in Android Simulator HOT 1
- Tweaks for using with Spotify OAuth HOT 2
- Feat: Integration with trapeze to improve configuration
- Auth0 HOT 1
- Bug: Intent filter not working for redirection after login HOT 2
- Feat: Support Android 13 HOT 2
- Support for Capacitor 5 HOT 10
- Is there a way to get a login prompt? HOT 1
- Azure B2C ui_locales is directly supported via the auth request builder exception HOT 2
- I am not able to hide URL bar HOT 2
- accessTokenEndpoint quirk with django backend HOT 1
- Google with android says "Custom scheme URIs are not allowed for 'WEB' client type" HOT 3
- App Store Connect Issue
- Hide navigation bar and footer on iOS HOT 5
- Evidence of the use of safari
- Question: What kind of browser is used for login? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from capacitor-oauth2.