Skip to content

Commit 8a1b762

Browse files
committed
Fix readme
1 parent d2d1de4 commit 8a1b762

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

docs/webview_oauth_signin.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ A **custom scheme** is a URL protocol that your app owns.
3434
Example:
3535

3636
```
37-
com.compassmeet:/auth
37+
com.compassmeet://auth
3838
```
3939

4040
or
@@ -63,7 +63,7 @@ localStorage.setItem('pkce_verifier', codeVerifier);
6363

6464
const params = new URLSearchParams({
6565
client_id: GOOGLE_CLIENT_ID,
66-
redirect_uri: 'com.compassmeet:/auth', // your deep link
66+
redirect_uri: 'com.compassmeet://auth', // your deep link
6767
response_type: 'code',
6868
scope: 'openid email profile',
6969
code_challenge: codeChallenge,
@@ -82,7 +82,7 @@ Here, `_system` (or using Capacitor Browser plugin) opens the **system browser**
8282
After login, Google redirects to your registered `redirect_uri`, e.g.:
8383

8484
```
85-
com.compassmeet:/auth?code=4/0AfJohXyZ...
85+
com.compassmeet://auth?code=4/0AfJohXyZ...
8686
```
8787

8888
---
@@ -100,13 +100,26 @@ In your **Android app code**, you register an intent filter in `AndroidManifest.
100100
</intent-filter>
101101
```
102102

103-
Then, in your app’s main activity (Kotlin/Java), you listen for deep links:
103+
Then, in your app’s main activity, you listen for deep links.
104+
In java:
105+
```java
106+
@Override
107+
protected void onNewIntent(Intent intent) {
108+
super.onNewIntent(intent);
104109

110+
String data = intent.getDataString();
111+
if (data != null && data.startsWith("com.compassmeet://auth")) {
112+
bridge.triggerWindowJSEvent("oauthRedirect", data);
113+
}
114+
}
115+
```
116+
117+
Or in Kotlin:
105118
```kotlin
106119
override fun onNewIntent(intent: Intent) {
107120
super.onNewIntent(intent)
108121
val data = intent.dataString
109-
if (data != null && data.startsWith("com.compassmeet:/auth")) {
122+
if (data != null && data.startsWith("com.compassmeet://auth")) {
110123
bridge.triggerWindowJSEvent("oauthRedirect", data)
111124
}
112125
}
@@ -133,7 +146,7 @@ window.addEventListener('oauthRedirect', async (event: any) => {
133146
client_id: GOOGLE_CLIENT_ID,
134147
code,
135148
code_verifier: codeVerifier!,
136-
redirect_uri: 'com.compassmeet:/auth',
149+
redirect_uri: 'com.compassmeet://auth',
137150
grant_type: 'authorization_code',
138151
}),
139152
});
@@ -174,10 +187,10 @@ However, universal links are more setup-heavy (require hosting a `.well-known/as
174187

175188
## 6. Summary
176189

177-
| Step | What happens | Where |
178-
| ---- | ------------------------------------------------------------- | -------------- |
179-
| 1 | Generate PKCE challenge and open Google OAuth URL | WebView |
180-
| 2 | User signs in | System browser |
181-
| 3 | Browser redirects to deep link (e.g. `com.compassmeet:/auth`) | OS → App |
182-
| 4 | App intercepts deep link and injects it into WebView | Native layer |
183-
| 5 | WebView exchanges `code` for tokens via PKCE | Web app |
190+
| Step | What happens | Where |
191+
| ---- |----------------------------------------------------------------| -------------- |
192+
| 1 | Generate PKCE challenge and open Google OAuth URL | WebView |
193+
| 2 | User signs in | System browser |
194+
| 3 | Browser redirects to deep link (e.g. `com.compassmeet://auth`) | OS → App |
195+
| 4 | App intercepts deep link and injects it into WebView | Native layer |
196+
| 5 | WebView exchanges `code` for tokens via PKCE | Web app |

0 commit comments

Comments
 (0)