首页 > 解决方案 > TypeError:无法读取 react-native-app-auth 中未定义的属性“授权”

问题描述

我试图在我的反应原生应用程序中包含 react-native-app-auth,但是每当我使用这些方法(比如授权或撤销)时,我都会收到以下错误

TypeError:无法读取未定义的属性“授权”。

在此处输入图像描述

这是我的代码

import { authorize } from 'react-native-app-auth'; accessTokenRequest = async () => { const config = { issuer: 'http://localhost:8080', clientId: 'am.identity.bpss.com', redirectUrl: 'http://localhost:3000/oauth-redirect', scopes: ['read','write'], usePKCE: true, serviceConfiguration: { authorizationEndpoint: "http://localhost:8080/oauth/authorize", tokenEndpoint: "http://localhost:8080/oauth/token", revocationEndpoint: "" }, }; // use the client to make the auth request and receive the authState try { const result = await authorize(config); console.log(result); } catch (error) { console.log(error); } }

当点击登录按钮时,我会调用这个函数。

这是我的 package.json

在此处输入图像描述

标签: react-nativeoauth-2.0

解决方案


推荐阅读