JavaScript 从 URL 中获取 OAuth 令牌
JavaScript grab OAuth token from URL?
我正在使用一个隐式使用 OAuth 的 API。它会重定向到 URL http://exmaple.com/#token=084758yhroufgbk48y。
我如何通过JavaScript获取它?谢谢
您可以使用
window.location.hash
获取URL的哈希部分
要从 url 获取令牌,请使用以下代码:
<script type="text/javascript">
hash = window.location.hash.substr(1); //url of the current page
arHash = hash.split('='); //this creates an array with key ([0] element) and value ([1] element)
hash_value = arHash[1]; //recieve value
</script>
相关文章:
- 如何使用Google撤销Oauth令牌'的Javascript API
- OAuth和访问令牌
- 如何获取登录用户的twitter oAuth令牌
- Axios CORS 问题与 Github oauth 未获取访问令牌
- 通过oauth令牌passport.js访问用户配置文件
- 使用 Angular.js 处理基于 OAuth 令牌的身份验证
- 如何在Windows 8 JavaScript(Metro)中将twitter oAuth请求令牌转换为访问令牌
- 在第二个请求中使用 oauth 令牌 - NODEJS
- 收到错误 401 未经授权,无法在 Twitter 中验证 OAuth 签名和令牌
- 通过请求从代码中获取 Dropbox OAuth 令牌.js失败;等效卷曲工作
- JavaScript 从 URL 中获取 OAuth 令牌
- 无法从OAuth Google API获取已安装应用程序的访问令牌
- 如何在OAuth 2.0中获取刷新令牌
- Google OAuth令牌过期
- Google选取器未使用OAuth令牌
- 无法使用jQuery执行POST请求以获取Strava OAuth令牌
- Google OAuth一次性并保存访问令牌以备将来使用(长期访问令牌)
- 如何在javascript中处理过期的Facebook oauth令牌
- 将OAuth令牌通信到javascript客户端的安全方式
- 获取没有秘密的github OAuth令牌