使用Azure AD进行身份验证-React Native

时间:2019-06-17 14:23:59

标签: azure react-native authentication azure-active-directory

我正在尝试使用此库'react-native-azure-ad2'向Azure进行身份验证,但似乎无法正常工作。登录后,它将显示以下错误消息:

很抱歉,我们无法登录。请求中指定的回复URL与为应用程序'xxxxxxxxxxxxxxxxxxxxxxxxx'配置的回复URL不匹配

这是我的代码:

    var credentials = {
    client_id: 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxx',
    client_secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    redirectUrl: 'msalxxxxxxx-xxxxxx-xxxxx-xxxxx-xxxxxxxxxx://auth',
    scope: 'User.Read'
};

export default class AzureLogin3 extends React.Component {

    constructor(props) {
        super(props);
        this.azureInstance = new AzureInstance(credentials);
        this._onLoginSuccess = this._onLoginSuccess.bind(this);
    }

    _onLoginSuccess() {
             this.azureInstance.getUserInfo().then(result => {
             console.log(result);
           }).catch(err => {
            console.log(err);
        })
    }

    render() {
        return (
            <AzureLoginView
                azureInstance={this.azureInstance}
                loadingMessage="Requesting access token"
                onSuccess={this._onLoginSuccess}
            />
        );
    }
}

我尝试了所有这些凭据并以不同的方式进行组合,但是错误消息仍然相同。

2 个答案:

答案 0 :(得分:0)

我认为您可以参考此doc

另外here是与此问题类似的另一个线程。请看一看。尽管那只是b2c只是在引用它是否有帮助。

答案 1 :(得分:0)

我认为您代码中的 redirectUrl 与注册的 Azure 应用程序的重定向 URI 中的不匹配。