capacitor-community / capacitor-community/generic-oauth2

Azure SSO; Response comes from azure, but does not come to authenticate

Open
#249 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
281
Forks
129
PR merge metrics
No merged PRs in 30d

Description

### Description

I call OAuth2Client.authenticate on android; the MS auth page opens and I click 'continue' to login with my MS account.

Then the logs show a returned object with the code in it.

The data is not returned to the promise though, with the promise response being undefined. (logs shown below)

Also I need token but when I change from code to token the whole thing fails.

2024-02-15 11:55:52.167 19164-19164 Capacitor io.ionic.i4m.omniascout D Unable to find a Capacitor plugin to handle requestCode, trying Cordova plugins 1389386085
2024-02-15 11:55:52.169 19164-19164 Capacitor/...ientPlugin io.ionic.i4m.omniascout I Authorization response:
{"request":{"configuration":{"authorizationEndpoint":"https:\/\/login.microsoftonline.com\/42c16220-86f6-46a1-9020-5c53af214eea\/oauth2\/v2.0\/authorize","tokenEndpoint":"https:\/\/login.microsoftonline.com\/42c16220-86f6-46a1-9020-5c53af214eea\/oauth2\/v2.0\/authorize"},"clientId":"a18ca770-a6a0-4fbe-973b-8f4a8dc48ed0","responseType":"code","redirectUri":"msauth:\/\/io.ionic.i4m.omniascout\/"scope":"https:\/\/graph.microsoft.com\/User.Read","state":"bjvvZvyicw33BYebmAMk","nonce":"zFJymOh5rG0RbIaUQ0xxEg","codeVerifier":"szk5g6P9ZrDiUimiZDbVSBJ9T4OGRZUPuSnBoM2jIXdvqWoIcYuQplfC9gDFQH5E","codeVerifierChallenge":"5NSX9DK54wZP1DOoyyUZiwfD_t1v8a3cDdhtAs7qCZA","codeVerifierChallengeMethod":"S256","responseMode":"query","additionalParameters":{}},"state":"bjvvZvyicw33BYebmAMk","code":"0.AREAIGLBQvaGoUaQIFxTryFO6nCnjKGgpr5PlzuPSo3EjtAXAa8.AgABAAIAAAAmoFfGtYxvRrNriQdPKIZ-AgDs_wUA9P-QUDgR5NHn5JhZqraxDpBtN3zmYa1fdMbdySJ8i8lWGCelaaDU4E-4LVXd5c1SmVxaFzAAgJduSswUkmiSznulv-uAwsYB_Mi_OKws3lr0pifogJNMEkBrGk2P0lmACV5_ZD01mwHcd8211Em53BPPeDfUUyfJQORPlz-_KhzZ0geAu4q1CZoQu7DAd2g0mZ0ePHtFuVZ1BpoIXANROn0zTDbsINMjxmO1O4gelHo4LzeUgoVIN6e8oJnzNyGd1W2qSGY37vZGGXShedI0WaNqoTEDb8YirJk_SOdAnw3-SPsPmUH5VGeJuDl4wkmfQWMvocLr2BkfDJ9-1zmAdXcwAx1QBwviFcWqZMbUHCe2IiUKZDDiAENHmjk_9y_0HLhz_hYaWqHKQ2zDPAh31zy1KZjrjcoNn4BuLE-MG0fQSXXFytGRbdAiO0lDWGEiB5-Oz6Ae6gtABUwXcLn5uuz0plKjo77K7STttJHQKkDsSUjzClb3JJUHpPE5K7RMi63XaB-sFyBMW7UoN1IdPZrgg4gHVG9vkwrq1kXMcd3pz-iahAFVN_oKDQsPBsUk6TU_LShrW4e_NaJiJSH-EwCo3R11GOcRCxuKaF1HKshpxbzB6sSAbDc05WLuhowfSCT2eSmMZXi5UhlJxKBqKwXh5oW2Cs5uAz0q7pZWc4CJ8h7TMtbM5ftER_FKlE9KbSqytPzlUQICaPU5rvxxoQE0ePBHxsaoztWfnn4qZQcbwlR1QUkRcJgXBpyGr60kOC6zLBIkIzXP0scfWiZub8QuTprlRqtbUBltAxVGi_s0hDrJQ9w1YYk9mgp2JGlFlqQzrnZW4-uBOQehqZMAmcK8dHc9n1E","additional_parameters":{"session_state":"aa41ca8d-fee5-4794-a2c3-f41907b14383"}}
2024-02-15 11:55:52.170 19164-19164 ViewRootIm...nActivity] io.ionic.i4m.omniascout I stopped(false) old = false
2024-02-15 11:55:52.171 19164-19164 Capacitor/AppPlugin io.ionic.i4m.omniascout D Firing change: true
2024-02-15 11:55:52.171 19164-19164 Capacitor/AppPlugin io.ionic.i4m.omniascout V Notifying listeners for event appStateChange
2024-02-15 11:55:52.171 19164-19164 Capacitor/AppPlugin io.ionic.i4m.omniascout V Notifying listeners for event resume
2024-02-15 11:55:52.172 19164-19164 ConnectivityManager io.ionic.i4m.omniascout D StackLog: [android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:4300)] [android.net.ConnectivityManager.registerDefaultNetworkCallbackForUid(ConnectivityManager.java:4864)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4831)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4805)] [com.capacitorjs.plugins.network.Network.startMonitoring(Network.java:138)] [com.capacitorjs.plugins.network.NetworkPlugin.handleOnResume(NetworkPlugin.java:60)] [com.getcapacitor.Bridge.onResume(Bridge.java:1284)] [com.getcapacitor.BridgeActivity.onResume(BridgeActivity.java:85)] [android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1531)] [android.app.Activity.performResume(Activity.java:8734)] [android.app.ActivityThread.performResumeActivity(ActivityThread.java:5351)] [android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5444)] [android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)] [android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)] [android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)] [android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)] [android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)]
2024-02-15 11:55:52.176 19164-19164 Capacitor io.ionic.i4m.omniascout D App resumed
2024-02-15 11:55:52.177 19164-19164 DecorView io.ionic.i4m.omniascout I notifyKeepScreenOnChanged: keepScreenOn=false
2024-02-15 11:55:52.182 19164-19291 Capacitor/NetworkPlugin io.ionic.i4m.omniascout V Notifying listeners for event networkStatusChange
2024-02-15 11:55:52.190 19164-19164 MSHandlerLifeCycle io.ionic.i4m.omniascout I removeMultiSplitHandler: no exist. decor=DecorView@a97b481[MainActivity]
2024-02-15 11:55:52.191 19164-19164 Capacitor/Console io.ionic.i4m.omniascout I File: http://localhost/src_app_map_map_module_ts.js - Line 10826 - Msg: =================================================
2024-02-15 11:55:52.191 19164-19164 Capacitor/Console io.ionic.i4m.omniascout I File: http://localhost/src_app_map_map_module_ts.js - Line 10827 - Msg: =================================================
2024-02-15 11:55:52.191 19164-19164 Capacitor/Console io.ionic.i4m.omniascout I File: http://localhost/src_app_map_map_module_ts.js - Line 10828 - Msg: MS SSO LOGIN RETURNED
2024-02-15 11:55:52.192 19164-19164 Capacitor/Console io.ionic.i4m.omniascout I File: http://localhost/src_app_map_map_module_ts.js - Line 10829 - Msg: =================================================
2024-02-15 11:55:52.192 19164-19164 Capacitor/Console io.ionic.i4m.omniascout I File: http://localhost/src_app_map_map_module_ts.js - Line 10830 - Msg: =================================================
2024-02-15 11:55:52.192 19164-19164 Capacitor/Console io.ionic.i4m.omniascout I File: http://localhost/src_app_map_map_module_ts.js - Line 10831 - Msg: MS SSO returned
2024-02-15 11:55:52.193 19164-19164 Capacitor/Console io.ionic.i4m.omniascout I File: http://localhost/src_app_map_map_module_ts.js - Line 10833 - Msg: undefined
2024-02-15 11:55:52.193 19164-19164 Capacitor/Console io.ionic.i4m.omniascout I File: http://localhost/src_app_map_map_module_ts.js - Line 10834 - Msg: undefined
2024-02-15 11:55:52.193 19164-19164 Capacitor/Console io.ionic.i4m.omniascout I File: http://localhost/src_app_map_map_module_ts.js - Line 10835 - Msg: undefined
2024-02-15 11:55:52.194 19164-19164 Capacitor/Console io.ionic.i4m.omniascout I File: http://localhost/ - Line 328 - Msg: undefined

### Capacitor version: 5

```
Replace this with the commands output
```

### Library version:
- 5.0.0

### OAuth Provider:
- Azure AD (B2C)

### Your Plugin Configuration

```typescript
{
appId: environment.oauthAppId.azureBc2.appId,
authorizationBaseUrl: 'https://login.microsoftonline.com/{... my stuff}/oauth2/v2.0/authorize',
scope: "https://graph.microsoft.com/User.Read", // See Azure Portal -> API permission
accessTokenEndpoint: 'https://login.microsoftonline.com/{...}/oauth2/v2.0/token',
responseType: "token",
pkceEnabled: true,
logsEnabled: true,
web: {
responseType: "token",
accessTokenEndpoint: "",
redirectUrl: 'http://localhost:8100/', //environment.redirectUrl,
},
android: {
accessTokenEndpoint: '',
responseType: "code",
redirectUrl: "msauth://io.ionic.i4m.omniascout/{...sig hash}"

},
ios: {
pkceEnabled: true, // workaround for bug #111
redirectUrl: "msauth.io.ionic.i4m.omniascout://auth"
},
additionalParameters: {
response_mode: "query"
}
}
```

### Affected Platform(s):

* Android
* Version/API Level: 33
* Device Model: Galaxy S4
* Content of your `AndroidManifest.xml`
```xml


























-->
```

Contributor guide

Open the contributing guide

Research direction

Start with OAuth2Client.authenticate on Android and the AndroidManifest.xml redirect handlers. Reproduce the issue using the supplied Azure AD B2C configuration and compare the logged authorization response with the promise result for the code and token response types. Done when the supported configuration and returned value are clear and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, typescript
Domain
authentication, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.