Моя задача состоит в том, чтобы настроить Google OAuth 2.0 для получения кода авторизации (не токен) для последующего использования.
Включение пользовательской схемы URI в Google Cloud Консоль не рекомендуется.
Итак, для этого я использую Приложения ссылки . p>
Что я сделал:
Добавлено https://example.com/.well-known/assetlinks.json с моим отдела отдела отладки пальца:
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.mypackage.app",
"sha256_cert_fingerprints":
["FB:34:15:34:8F:6B:[...]"]
}
}]
< /code>
Добавлен фильтр для намерения: < /p>
< /code>
Используется Appauth-android для создания запроса: < /p>
val serviceConfiguration = AuthorizationServiceConfiguration(
Uri.parse("https://accounts.google.com/o/oauth2/v2/auth"), // Authorization endpoint
Uri.parse("https://www.googleapis.com/oauth2/v4/token") // Token endpoint
)
val redirect = "https://example.com"
val authRequestBuilder = AuthorizationRequest.Builder(
serviceConfiguration, // the authorization service configuration
GOOGLE_CLIENT_ID, // the client ID
ResponseTypeValues.CODE, // the response_type value: we want a code
Uri.parse(redirect)) // the redirect URI to which the auth response is sent
val authRequest = authRequestBuilder
.setScope("openid email profile")
.setState(state)
.build()
val authService = AuthorizationService(this)
// An Intent that will handle the redirect result
val redirectIntent = Intent(this, SignUpActivity::class.java)
.setAction(redirect)
authService.performAuthorizationRequest(
authRequest,
PendingIntent.getActivity(this, 0, redirectIntent, PendingIntent.FLAG_IMMUTABLE)
)
< /code>
Я также тестировал ссылку на приложение, как говорят документы для Android, IT показывает, что ссылка приложения работает (перенаправить меня напрямую и немедленно в мое приложение): < /p>
adb shell am start -a android.intent.action.VIEW \
-c android.intent.category.BROWSABLE \
-d "http://example.com"
< /code>
В Google Cloud Console мой идентификатор клиента для Android Page выглядит так (и я не уверен, что здесь делать):
Можете ли вы помочь мне найти корень проблемы, пожалуйста?
Подробнее здесь: https://stackoverflow.com/questions/793 ... i-mismatch