私たちは、AppAuth-Android hereでのハイブリッドフローのサポートについて未解決の問題があります。これの主な問題は、アクセストークンが期限切れになるたびにSafariViewController/CustomTab経由でウェブフローを繰り返しトリガする必要があるため、ハイブリッドフローがモバイルアプリケーションに適していないことです。リフレッシュトークンを取得して、アクセストークンのバックグラウンド更新を許可することは、ネイティブアプリにとってはより良い方法です。
IdentityServer3は認定OpenID Connectの実装であるため、認証コードフローを使用してリフレッシュトークンを取得できる必要があります。
new Client
{
ClientId = "myClientId",
ClientName = "myClientName",
AllowedGrantTypes = GrantTypes.CodeAndClientCredentials,
RequireConsent = false,
ClientSecrets =
{
new Secret("myClientSecret".Sha256())
},
RedirectUris = { "myRedirectUri://callback" },
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
IdentityServerConstants.StandardScopes.Phone,
},
AllowOfflineAccess = true
}
クリックログインのAndroidで:
AuthManager authManager = AuthManager.getInstance(this);
AuthorizationService authService = authManager.getAuthService();
Auth auth = authManager.getAuth();
AuthorizationRequest authRequest = new AuthorizationRequest
.Builder(
authManager.getAuthConfig(),
auth.getClientId(),
auth.getResponseType(),
Uri.parse(auth.getRedirectUri()))
.setScope(auth.getScope())
.build();
Intent authIntent = new Intent(this, LoginAuthActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, authRequest.hashCode(), authIntent, 0);
authService.performAuthorizationRequest(
authRequest,
pendingIntent);
を求める
を確認することができ、このoidcライブラリは、クエリ文字列などを期待している間に許可応答は、リダイレクトURIにフラグメントとして返されるためでありますその応答では、図書館は応答を得ることに成功していません。 ライブラリは仕様に従っていませんが、実際にはどちらのライブラリもハイブリッドフローをサポートしているとは疑いがあります。 それらのライブラリはGoogleのIdPのケースを処理しており、それは実装者のためのものです。 –
ライブラリはGoogle固有のものではありません。彼らはネイティブアプリケーション用のOAuth2の推奨事項を実装しています:https://tools.ietf.org/html/draft-ietf-oauth-native-apps-07 – iainmcgin