솜은 코튼
[error] 403. Error: disallowed_useragent. 본문
[오류 사항]
403. Error: disallowed_useragent.
Google can't sign you safety inside this app. You can use Google sign-in by visiting this app's website in a browser like Safari or Chrome.
[오류 원인]
WebView로 된 인앱 브라우저로 Google OAuth 2.0 링크를 여는 경우
Android OS에서 구글 인증을 Web방식으로 할 때 발생.
구글이 2016년 10월 20일부터 WebView로 구글 인증을 하지 못하도록 막았기 때문이다.
[해결 방법]
구글 인증 링크를 WebView로 구현된 인앱 브라우저가 아닌 ChromeCustomTabs로 열거나,
WebView를 열 때 user-agent를 변경하여 우회한다.
1) ChromeCustomTabs 사용 방법
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
Uri uri = Uri.parse("[호출할 url]");
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
// Begin customizing
// Set toolbar colors
intentBuilder.setToolbarColor(ContextCompat.getColor(callerObject, R.color.browser_actions_bg_grey));
intentBuilder.setSecondaryToolbarColor(ContextCompat.getColor(callerObject, R.color.browser_actions_bg_grey));
// set start and exit intent
CustomTabsIntent customTabsIntent = intentBuilder.build();
// launch the url
// customTabsIntent.launchUrl(MainActivity, uri);
customTabsIntent.launchUrl(callerObject, uri);
|
cs |
1) user-agent를 변경하여 우회하는 방법
1
2
|
String USER_AGENT = "Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19";
webview.getSettings().setUserAgentString(USER_AGENT);
|
cs |
'Android > 오류사항' 카테고리의 다른 글
[error] select an element in the page to inspect it / chrome inspect touch cursor not working (0) | 2021.01.07 |
---|---|
[error] Google Login Api Fail(실패) 원인 (0) | 2021.01.07 |
[error] java.io.FileNotFoundException (0) | 2020.10.23 |
[error] Manifest merger failed with multiple errors, see logs (0) | 2020.10.19 |
[error] INSTALL_FAILED_CONFLICTING_PROVIDER (0) | 2020.09.03 |