Skip to content

Commit 542ef9b

Browse files
docs: READMEの更新
- AndroidManifest.xmlの`<activity>`の名前を`com.linusu.flutter_web_auth.CallbackActivity`から`com.linusu.flutter_web_auth_2.CallbackActivity`に変更 - Androidの`<intent-filter>`に関する重要な注意事項を追加 - OAuthリダイレクトに関する詳細な説明を追加し、一般的なエラーの原因を明記
1 parent 6fa7997 commit 542ef9b

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,15 @@ Add to `ios/Runner/Info.plist`:
150150
Add to `android/app/src/main/AndroidManifest.xml`:
151151

152152
```xml
153-
<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" android:exported="true">
154-
<intent-filter android:label="flutter_web_auth_2">
153+
<activity android:name="com.linusu.flutter_web_auth_2.CallbackActivity" android:exported="true">
154+
<intent-filter>
155155
<action android:name="android.intent.action.VIEW" />
156156
<category android:name="android.intent.category.DEFAULT" />
157157
<category android:name="android.intent.category.BROWSABLE" />
158+
<!-- Minimum: scheme only -->
158159
<data android:scheme="yourscheme" />
160+
<!-- Optional (recommended when you control redirect.html): also restrict host/path -->
161+
<!-- <data android:scheme="yourscheme" android:host="oauth" android:path="/callback" /> -->
159162
</intent-filter>
160163
</activity>
161164
```
@@ -165,6 +168,18 @@ Notes:
165168
- On Android 12+ (API level 31+), any Activity with an `intent-filter` must declare `android:exported="true"`.
166169
- Use the same callback scheme string on both platforms: iOS (`CFBundleURLSchemes`) and Android (`<data android:scheme="...">`). They must match exactly.
167170

171+
Important (OAuth redirect on Android):
172+
- Misskey OAuth requires `redirect_uri` to be HTTPS and exactly match the link in your client_id page.
173+
- Typical pattern is:
174+
- `client_id` = `https://yourpage/yourapp/`
175+
- `redirect_uri` = `https://yourpage/yourapp/redirect.html`
176+
- The `redirect.html` then navigates to your custom scheme: `yourscheme://oauth/callback?code=...&state=...`
177+
- If you restrict the Android intent-filter by host/path, make sure it matches the URL used in `redirect.html` (e.g., `yourscheme://oauth/callback`).
178+
- If you see `PlatformException(CANCELED, User canceled login, ...)` on Android, common causes are:
179+
1) The device did not deliver the callback to the app. Ensure `com.linusu.flutter_web_auth_2.CallbackActivity` has a matching `<intent-filter>`.
180+
2) A PWA or another app intercepted the link. Using HTTPS → `redirect.html` → custom scheme flow usually mitigates this.
181+
3) The `redirect_uri` did not exactly match the `<link rel="redirect_uri">` in the client_id page.
182+
168183
#### Differences in MiAuth and OAuth Configuration (Key Points for App Integration)
169184
- This configuration (registration of the URL scheme) is done on the "app side." It is not included in the library's Manifest.
170185
- Both methods require a "custom URL scheme" to return from an external browser to the app.

0 commit comments

Comments
 (0)