rest - 在 GET URL 中指定 OAuth token

标签 rest oauth get oauth-2.0 bearer-token

我的 REST 服务使用 OAuth 2.0 身份验证。我想使用浏览器(不使用客户端)测试一些 GET URL。我可以在 URL 中传递不记名 token 吗?
网址:www.example.com/employee/employeeId

最佳答案

您可以在 access_token 中传递它查询参数,见https://www.rfc-editor.org/rfc/rfc6750#section-2.3 ,但正如另一个答案中所述,它不是传递 token 的首选方式。它可能最终出现在日志、浏览器缓存等中。在这个方法中,规范说:

Because of the security weaknesses associated with the URI method
(see Section 5), including the high likelihood that the URL
containing the access token will be logged, it SHOULD NOT be used
unless it is impossible to transport the access token in the
"Authorization" request header field or the HTTP request entity-body. Resource servers MAY support this method.

This method is included to document current use; its use is not
recommended, due to its security deficiencies (see Section 5) and
also because it uses a reserved query parameter name, which is
counter to URI namespace best practices, per "Architecture of the
World Wide Web, Volume One" [W3C.REC-webarch-20041215].


因此,您还应该意识到资源服务器(或 API)甚至可能不支持这种 token 传递方法。唯一必须实现的方法是 Authorization 头方法。

关于rest - 在 GET URL 中指定 OAuth token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29926041/

相关文章:

java - RestTemplate.postForObject 和列表

android - 在我的 Android 应用程序之间共享 oauth token - 共享用户 ID、钥匙串(keychain)、AccountManager 或其他?

python - 谷歌oauth登录Python : "Invalid parameter value for redirect_uri: Missing scheme: None"

node.js - 服务器之间通信的安全方式

http - 通过 REST (RESTful) API 进行批量集合操作

java - 谷歌云平台不返回任何内容

oauth - 从 COBOL CICS WEB CONVERSE 生成 OAuth 访问 token - 'error_description : grant_type is required'

php - 在这段 JavaScript 代码中包含变量的正确语法是什么?

jQuery GET 到同一域上的 API 会出现 CORS 错误

api - Mailtrap API - 无法发送电子邮件 - "Unauthorized"API 错误