【发布时间】:2018-07-22 15:44:06
【问题描述】:
我正在尝试从我的 spring 后端 api 执行 this call。我已经拥有客户发送给我的访问令牌。这段代码的 java 等效项是什么?:
// Script uses auth0.js. See Remarks for details.
<script src="https://cdn.auth0.com/js/auth0/9.0.1/auth0.min.js"></script>
<script type="text/javascript">
// Initialize the Auth0 client
var webAuth = new auth0.WebAuth({
domain: '{domain}',
clientID: '{clientId}'
});
// Parse the URL and extract the access_token
webAuth.parseHash(window.location.hash, function(err, authResult) {
if (err) {
return console.log(err);
}
webAuth.client.userInfo(authResult.accessToken, function(err, user) {
// This method will make a request to the /userinfo endpoint
// and return the user object, which contains the user's information,
// similar to the response below.
});
});
</script>
来自客户端的访问令牌的详细信息(我删除了一些详细信息并用方括号替换了它们):
~~~~~~~~~ JWT Header ~~~~~~~
JWT Header : {"typ":"JWT","alg":"RS256","kid":"[kid]"}
~~~~~~~~~ JWT Body ~~~~~~~
JWT Body : {"iss":"https://demo.auth0.com/","sub":"google-oauth2|[my id here]","aud":["[api audience]","https://demo.auth0.com/userinfo"],"iat":[number],"exp":[expiry],"azp":"[azp]","scope":"openid"}
【问题讨论】:
标签: javascript java android spring auth0