「[[.NET 開発基盤部会 Wiki>http://dotnetdevelopmentinfrastructure.osscons.jp]]」は、「[[Open棟梁Project>https://github.com/OpenTouryoProject/]]」,「[[OSSコンソーシアム .NET開発基盤部会>https://www.osscons.jp/dotNetDevelopmentInfrastructure/]]」によって運営されています。 -[[戻る>Flutter]] --...[[Flutterの5thステップ]] --[[Flutterのファースト・ステップ2]] --[[Flutterのセカンド・ステップ2]] --Flutterのサード・ステップ2 *目次 [#g1dc9c7a] #contents *概要 [#mc2d02da] OAuth系認証・認可処理を実装 *詳細 [#u588d16a] [[以前のバージョンではAppAuthで認証処理を実装していたが>Flutterのセカンド・ステップ#t89cc4af]]、~ Windowsデスクトップ版を実装するにあたり問題が発生して、自前実装が必要になった。 **フォルダ構成 [#c43b6070] ヘッダにボタンを用意して、認証処理をmain_layoutではなくauth_serviceに実装する。 ヘッダにボタンを用意して、認証処理を...に実装する。 lib/ ├── main.dart # Provider登録 ├── services/ │ └── auth_service.dart # 認証ロジック ├── layouts/ │ └── main_layout.dart # ロジックなし └── widgets/ └── app_header.dart # UIのみ **カスタムURLスキーム [#ud464fdb] Windowsデスクトップ版でというのがポイント ***EXEの位置 [#r0b5cb7c] 以下の辺りにEXEがある。 \flutter_template\build\windows\x64\runner\Debug ***レジストリ登録 [#f47c687f] -登録内容 HKEY_CLASSES_ROOT\ myapp\ (Default) = "URL:myapp Protocol" URL Protocol = "" shell\ open\ command\ (Default) = "C:\path\to\your\app.exe" "%1" -登録処理(PowerShell) --登録 # register_scheme.ps1 $scheme = "myapp" $exePath = "C:\Path\To\YourApp.exe" # 実際のパスに変更 $keyPath = "HKCU:\Software\Classes\$scheme" New-Item -Path $keyPath -Force | Out-Null Set-ItemProperty -Path $keyPath -Name "(Default)" -Value "$scheme Protocol" Set-ItemProperty -Path $keyPath -Name "URL Protocol" -Value "" New-Item -Path "$keyPath\shell\open\command" -Force | Out Null Set-ItemProperty -Path "$keyPath\shell\open\command" -Name "(Default)" -Value "`"$exePath`" `"%1`"" Write-Host "登録完了: $scheme://" --解除 # unregister_scheme.ps1 $scheme = "myapp" $keyPath = "HKCU:\Software\Classes\$scheme" if (Test-Path $keyPath) { Remove-Item -Path $keyPath -Recurse -Force Write-Host "解除完了: $scheme://" } else { Write-Host "登録が見つかりません: $scheme://" } ***ハンドラ [#he5a0ec1] **インストール [#haf755e2] flutter pub add flutter_appauth *参考 [#v0d77f1a] -FrontendTemplates/UI/XPlat at develop · OpenTouryoProject/FrontendTemplates~ https://github.com/OpenTouryoProject/FrontendTemplates/tree/develop/UI/XPlat/ --https://github.com/OpenTouryoProject/FrontendTemplates/tree/develop/UI/XPlat/flutter_template --https://github.com/OpenTouryoProject/FrontendTemplates/tree/develop/UI/XPlat/old/flutter_template