【发布时间】:2020-10-03 02:19:48
【问题描述】:
我正在尝试创建一个在另一个应用程序的标头中传递 JWT 的登录应用程序。
我从这个应用程序开始 User authentication keycloak 2 适应我的 Kecloak 安装,它工作正常。 现在我需要创建一个调用外部 URL 并传递授权令牌的组件
在这个组件中
import React, { Component } from 'react';
class callUrl1 extends Component {
constructor(props) {
super(props);
this.state = { response: null };
}
authorizationHeader() {
if(!this.props.keycloak) return {};
return {
headers: {
"Authorization": "Bearer " + this.props.keycloak.token
}
};
}
handleClick = () => {
console.log("callUrl1 called")
}
}
export default callUrl1;
我需要调用外部 URL 的东西;类似:
SOME_FUNCTION('https://www.h.net/users', this.authorizationHeader())
放入handleClick。
我尝试的所有方法都会出现编译错误。
如何通过 JWT 从“http://localhost:3000”转到“https://www.h.net/users”?
【问题讨论】:
标签: node.js reactjs jwt keycloak