Skip to content

Commit 4d5f733

Browse files
Merge pull request #8 from LibraryLibrarian/feature/retry
feat: リトライ機能を追加
2 parents 0e41ed0 + f4023ee commit 4d5f733

7 files changed

Lines changed: 304 additions & 125 deletions

File tree

README.md

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Add to `android/app/src/main/AndroidManifest.xml`:
151151

152152
```xml
153153
<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" android:exported="true">
154-
<intent-filter android:label="flutter_web_auth">
154+
<intent-filter android:label="flutter_web_auth_2">
155155
<action android:name="android.intent.action.VIEW" />
156156
<category android:name="android.intent.category.DEFAULT" />
157157
<category android:name="android.intent.category.BROWSABLE" />
@@ -160,12 +160,17 @@ Add to `android/app/src/main/AndroidManifest.xml`:
160160
</activity>
161161
```
162162

163+
Notes:
164+
- The `android:label` attribute on the `<intent-filter>` is optional. You can omit it or set any string.
165+
- On Android 12+ (API level 31+), any Activity with an `intent-filter` must declare `android:exported="true"`.
166+
- Use the same callback scheme string on both platforms: iOS (`CFBundleURLSchemes`) and Android (`<data android:scheme="...">`). They must match exactly.
167+
163168
#### Differences in MiAuth and OAuth Configuration (Key Points for App Integration)
164169
- This configuration (registration of the URL scheme) is done on the "app side." It is not included in the library's Manifest.
165170
- Both methods require a "custom URL scheme" to return from an external browser to the app.
166171
- The difference lies in how to specify "where to return from the browser."
167172
- OAuth: Since it needs to return to an HTTPS `redirect_uri` from the authorization server, `redirect.html` placed there ultimately redirects back to `yourscheme://...` for the app.
168-
- MiAuth: The `callback` query of the authentication start URL specifies `yourscheme://...` from the beginning (no need for `https`).
173+
- MiAuth: The `callback` query of the authentication start URL points to the app via the custom scheme only (e.g., `yourscheme://`). No `https` is needed.
169174

170175
##### Example of MiAuth (no persistence)
171176

@@ -180,7 +185,7 @@ final miConfig = MisskeyMiAuthConfig(
180185
permissions: ['read:account', 'write:notes'],
181186
iconUrl: 'https://example.com/icon.png', // Optional
182187
);
183-
final miRes = await miClient.authenticate(miConfig); // returns token only
188+
final miRes = await miClient.authenticate(miConfig); // returns token (and user if available)
184189
```
185190

186191
##### Example of MiAuth (with persistence via MisskeyAuthManager)
@@ -241,12 +246,12 @@ final current = await auth.currentToken();
241246

242247
##### How to Support Both Methods in the Same App
243248
- By registering the same `scheme` (e.g., `yourscheme`) in iOS's `Info.plist` and Android's `AndroidManifest.xml`, it can be shared between OAuth and MiAuth.
244-
- If you implement the OAuth `redirect.html` to redirect to `yourscheme://oauth/callback?...`, you can reuse the same path expression (`yourscheme://oauth/callback`) for MiAuth's `callback`.
249+
- This library uses a scheme-only callback for MiAuth (e.g., `yourscheme://`). You do not need to reuse a path like `yourscheme://oauth/callback` for MiAuth.
245250
- For Android, matching only on the `scheme` is sufficient as shown below (the `host` and `path` are optional).
246251

247252
```xml
248253
<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" android:exported="true">
249-
<intent-filter android:label="flutter_web_auth">
254+
<intent-filter android:label="flutter_web_auth_2">
250255
<action android:name="android.intent.action.VIEW" />
251256
<category android:name="android.intent.category.DEFAULT" />
252257
<category android:name="android.intent.category.BROWSABLE" />
@@ -296,6 +301,7 @@ class MisskeyMiAuthClient {
296301
/// Authenticate with Misskey server using MiAuth (no persistence)
297302
Future<MiAuthTokenResponse> authenticate(MisskeyMiAuthConfig config);
298303
}
304+
```
299305

300306
#### MisskeyAuthManager
301307

@@ -358,7 +364,6 @@ class AccountEntry {
358364
final DateTime? createdAt;
359365
}
360366
```
361-
```
362367

363368
### Error Handling
364369

@@ -379,7 +384,7 @@ The library includes exception classes for:
379384

380385
### License
381386

382-
This project is licensed under the 3-Clause BSD License - see the [LICENSE](LICENSE) file for details.
387+
This project is published by 司書 (LibraryLibrarian) under the 3-Clause BSD License. For details, please see the [LICENSE](LICENSE) file.
383388

384389
### Related Links
385390

@@ -416,26 +421,6 @@ dependencies:
416421
417422
### クイックスタート
418423
419-
#### かんたん例(MisskeyAuthManager)
420-
421-
```dart
422-
import 'package:misskey_auth/misskey_auth.dart';
423-
424-
final auth = MisskeyAuthManager.defaultInstance();
425-
426-
// 認証後にトークンを自動保存
427-
final key = await auth.loginWithOAuth(
428-
MisskeyOAuthConfig(
429-
host: 'misskey.io',
430-
clientId: 'https://yourpage/yourapp/',
431-
redirectUri: 'https://yourpage/yourapp/redirect.html',
432-
scope: 'read:account write:notes',
433-
callbackScheme: 'yourscheme',
434-
),
435-
setActive: true,
436-
);
437-
```
438-
439424
#### 1. client_idページの設定
440425
441426
MisskeyのOAuth 2.0はIndieAuth仕様に準拠しています。以下が必要です:
@@ -549,7 +534,7 @@ await auth.signOutAll();
549534

550535
```xml
551536
<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" android:exported="true">
552-
<intent-filter android:label="flutter_web_auth">
537+
<intent-filter android:label="flutter_web_auth_2">
553538
<action android:name="android.intent.action.VIEW" />
554539
<category android:name="android.intent.category.DEFAULT" />
555540
<category android:name="android.intent.category.BROWSABLE" />
@@ -558,13 +543,18 @@ await auth.signOutAll();
558543
</activity>
559544
```
560545

546+
補足:
547+
- `<intent-filter>``android:label` は省略可能です(省略しても動作します)。
548+
- Android 12+(API 31 以降)では、`intent-filter` を持つ Activity に `android:exported="true"` の指定が必須です。
549+
- iOS(`CFBundleURLSchemes`)と Android(`<data android:scheme="...">`)で登録するカスタムスキーム名は同一にしてください(完全一致が必要)。
550+
561551
#### MiAuth と OAuth の設定の違い(アプリ組み込み時のポイント)
562552

563553
- この設定(URLスキームの登録)は「アプリ側」で行います。ライブラリ内のManifestには含めません。
564554
- 両方式とも、外部ブラウザからアプリへ戻すために「カスタムURLスキーム」が必要です。
565555
- 相違点は「ブラウザからどこに戻すか」の指定方法です。
566556
- OAuth: 認可サーバーからはHTTPSの`redirect_uri`に戻る必要があるため、そこに配置した`redirect.html`が最終的に`yourscheme://...`へリダイレクトしてアプリに戻します。
567-
- MiAuth: 認証開始URLの`callback`クエリに、最初から`yourscheme://...`を指定します(`https`は不要)。
557+
- MiAuth: 認証開始URLの`callback`クエリには、アプリのカスタムスキームのみ(例: `yourscheme://`を指定します(`https`は不要)。
568558

569559
##### MiAuth の例(保存無し)
570560

@@ -579,7 +569,7 @@ final miConfig = MisskeyMiAuthConfig(
579569
permissions: ['read:account', 'write:notes'],
580570
iconUrl: 'https://example.com/icon.png', // 任意
581571
);
582-
final miRes = await miClient.authenticate(miConfig); // トークンのみ返します
572+
final miRes = await miClient.authenticate(miConfig); // トークン(必要に応じて user も)を返します
583573
```
584574

585575
##### MiAuth の例(MisskeyAuthManager による保存あり)
@@ -640,13 +630,13 @@ final current = await auth.currentToken();
640630

641631
##### 両方式を同一アプリでサポートするには
642632

643-
- iOSの`Info.plist`・Androidの`AndroidManifest.xml`で同じ`sheme`(例: `yourscheme`)を1つ登録すれば、OAuth/MiAuthで共用可能です。
644-
- OAuth用の`redirect.html`は、`yourscheme://oauth/callback?...`へ飛ばす実装にしておくと、MiAuthの`callback`でも同じパス表現(`yourscheme://oauth/callback`)を使い回せます
633+
- iOSの`Info.plist`・Androidの`AndroidManifest.xml`で同じ`scheme`(例: `yourscheme`)を1つ登録すれば、OAuth/MiAuthで共用可能です。
634+
- 本ライブラリの MiAuth は scheme のみ(`yourscheme://`)を callback に使います。`yourscheme://oauth/callback` のようなパス付きに揃える必要はありません
645635
- Androidは以下のように`scheme`のみのマッチで十分です(`host``path`は任意)。
646636

647637
```xml
648638
<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" android:exported="true">
649-
<intent-filter android:label="flutter_web_auth">
639+
<intent-filter android:label="flutter_web_auth_2">
650640
<action android:name="android.intent.action.VIEW" />
651641
<category android:name="android.intent.category.DEFAULT" />
652642
<category android:name="android.intent.category.BROWSABLE" />
@@ -777,7 +767,7 @@ class AccountEntry {
777767

778768
### ライセンス
779769

780-
このプロジェクトは3-Clause BSD Licenseの下で公開されています。詳細は[LICENSE](LICENSE)ファイルをご覧ください。
770+
このプロジェクトは司書(LibraryLibrarian)によって、3-Clause BSD Licenseの下で公開されています。詳細は[LICENSE](LICENSE)ファイルをご覧ください。
781771

782772
### リンク
783773

assets/demo_thumb.gif

-156 KB
Loading

0 commit comments

Comments
 (0)