우리는 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
}
클릭 로그인에 안드로이드에서 :
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