admin管理员组文章数量:1130349
android webview google登录授权的时候遇到了这个错误 403: Error: disallowed_useragent
解决方法:
String ua = webview.getSettings().getUserAgentString();
//ua的值等于getUAInfo() 函数获取的值。
webview.getSettings().setUserAgentString(getUAInfo().replace("; wv", ""));
//解决这个问题最关键的地方是,去除UA中的字符串“; wv” 去除成功之后,google授权登录就不会403错误了。
private String getUAInfo() {
String userAgent = "";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
try {
userAgent = WebSettings.getDefaultUserAgent(this);
} catch (Exception e) {
userAgent = System.getProperty("http.agent");
}
} else {
userAgent = System.getProperty("http.agent");
}
StringBuffer sb = new StringBuffer();
for (int i = 0, length = userAgenandroid webview google登录授权的时候遇到了这个错误 403: Error: disallowed_useragent
解决方法:
String ua = webview.getSettings().getUserAgentString();
//ua的值等于getUAInfo() 函数获取的值。
webview.getSettings().setUserAgentString(getUAInfo().replace("; wv", ""));
//解决这个问题最关键的地方是,去除UA中的字符串“; wv” 去除成功之后,google授权登录就不会403错误了。
private String getUAInfo() {
String userAgent = "";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
try {
userAgent = WebSettings.getDefaultUserAgent(this);
} catch (Exception e) {
userAgent = System.getProperty("http.agent");
}
} else {
userAgent = System.getProperty("http.agent");
}
StringBuffer sb = new StringBuffer();
for (int i = 0, length = userAgen本文标签: 解决方法详细Androiderroruseragent
版权声明:本文标题:Android 403: Error: Disallowed Useragent 问题解决方法详细记录 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/jiaocheng/1754941801a2744415.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论