- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在一个类中有以下代码:
@Override
public boolean shouldOverrideUrlLoading(WebView wv, String url)
{
if (url.startsWith(Constants.OAUTH_REDIRECT))
{
Uri uri = Uri.parse(url);
String state = uri.getQueryParameter("state");
if (state != null && state.equals(Constants.randString))
{
String error = uri.getQueryParameter("error");
if (error != null && error.length() > 0)
{
if (error.equals("access_denied"))
{
//user chose not to login
Log.d("oAuthView", "Access Denied");
finish();
}
else
{
Toast.makeText(getApplicationContext(), error, Toast.LENGTH_LONG).show();
finish();
}
}
//Go back to MainActivity with authorization code
Intent resultIntent = getIntent();
resultIntent.putExtra("authCode", uri.getQueryParameter("code"));
setResult(RESULT_OK, resultIntent);
finish();
return true;
}
}
return false;
}
出于某种原因,我在 try catch “状态”时得到了一个空值,即使我已经确定它在 URL 中。这意味着应用程序永远不会输入后面的 if 语句。我也检查过,当我 try catch authCode 时,同样的事情发生了。关于为什么他们会返回 null 的任何想法?
编辑:出于某种原因,当我尝试替代 URL 方案时,它解析正确。
我需要解析但不起作用的 URL: http://www.website.com/#access_token=tokenstringhere&token_type=bearer&state=randomStringHere&expires_in=3600&scope=identity+submit
一个类似的有效网址: http://www.website.com/?state=cnmdr6&code=tokenStringHere
什么会导致第一次解析失败但第二次解析正确?
最佳答案
如果有人正在寻找解决方案。
您的网址无效,因为您在网址查询前错过了问号 ?
。您的网址应如下所示:http://www.website.com/?access_token=tokenstringhere&token_type=bearer&state=randomStringHere&expires_in=3600&scope=identity+submit
请查看 documentation .
关于java - uri.getQueryParameter() 返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32729669/
我在一个类中有以下代码: @Override public boolean shouldOverrideUrlLoading(WebView wv, String url)
我已经做了很多搜索,但我未能找到 reqParam = $.getQueryParameters(); 这段代码的含义以及 ajax java 脚本的用途。我从某人的网站示例中复制了 java 脚本代
问题就像 uri.getQueryParameters() 方法正在将 Character(+) 转换为我试图避免的空间。 下面是之前的uri "http://localhost:8081/servi
我是 OAuth 新手,我正在开发一个需要 OAuth 的 Android 应用程序,并且我正在使用路标库。 我相信我已经完成了所有工作,直到我可以使用它来获取 token String token
我是 Web 服务的新手,在创建接受 GET 请求的 Web 服务时,我发现了两种可以读取 URL 参数的方法: UriInfo 的 getPathParameters() 和 getQueryPar
我有以下 URI:http://host/path?param1=1¶m2[]=2¶m3[1]=3 uri.getQueryParameterNames() 返回一个包含预期值 ["p
我想用 javax.ws.rs.client.Initation 等替换已弃用的类型 ClientRequest。但是,缺少 getPathParameters 和 getQueryParameter
我知道我可以解决这个问题,但与将参数从参数映射(应根据 javadoc 解码)中拉出相比,如果使用带注释的查询参数,行为会有所不同,这似乎很奇怪。这是一个错误,还是一个怪癖? @GET @Path("
我正在使用 JAX-RS 创建 RESTful 网络服务。我创建了一个这样的 API: GET /articles?userId= UI 调用此 API 并传递编码 userId,例如: GET /a
假设我有一个带值的 URI 参数,其中包含加号 (+) 和其他特殊字符。 当我执行 URI::setQueryParameters 然后执行 URI::getQueryParameters 时,结果值
我的生产应用最近开始遇到这种崩溃。 完整的 StackTrace 如下: Fatal Exception: java.lang.RuntimeException: Unable to start re
我是一名优秀的程序员,十分优秀!