我正在编写一个使用Microsoft Azure的sso将用户登录到该应用程序的react native应用程序。
我选择了这个库,它似乎运行良好,但是当我尝试获取用户信息时,它返回s“ CompactToken解析失败,错误代码:80049217。
我尝试从Internet上其他任何地方进行修复,都无济于事。
我的授权标头是
headers: {
'Authorization': "Bearer " + this.token.accessToken,
}
我还正确设置了权限,这仅仅是库问题,我需要更改库还是我做错了什么。
我的LoginScreen类
export default class SSOScreen extends React.Component {
constructor(props) {
super(props)
const CREDENTIAILS = {
client_id: '<client_id>',
client_secret: '<client_secret>',
scope: 'User.ReadBasic.All',
redirect_uri: 'https://login.microsoftonline.com/common/oauth2/nativeclient'
};
this.azureInstance = new AzureInstance(CREDENTIAILS);
this._onLoginSuccess = this._onLoginSuccess.bind(this);
}
render() {
console.log(this.azureInstance);
return (
<AzureLoginView
azureInstance={this.azureInstance}
loadingMessage="Requesting access token"
onSuccess={this._onLoginSuccess}
/>
);
}
_onLoginSuccess(){
this.azureInstance.getUserInfo().then(result => {
console.log(result);
}).catch(err => {
console.log(err);
})
}
}
如果我在onLoginSuccess中登录this.azureInstance.token,我会得到
Object {
"accessToken": undefined,
"expires_in": NaN,
"refreshToken": undefined,
}