react-native - [错误:ExpoAppAuth.Get Auth:JSON 反序列化错误]
问题描述
使用“expo-app-auth”中的 AppAuth 时出错;
当我尝试 authi 得到以下错误:[错误:ExpoAppAuth.Get Auth:JSON 反序列化错误]
const config = {
serviceConfiguration: {
authorizationEndpoint: 'https://api.netatmo.com/oauth2/authorize',
tokenEndpoint: 'https://api.netatmo.com/oauth2/token',
},
clientId: 'cilentid',
clientSecret: 'cilentsecret',
scopes: ['read_presence']
}
是不是和配置有关?
解决方案
您的配置无效。
这与https://github.com/expo/expo/pull/5311中的问题有关- expo-app-auth 中的三元运算符中存在错误,该错误将滚入即将发布的版本中。同时,您必须在服务配置对象中为registrationEndpoint 指定一个虚拟值。
const config = {
issuer: 'https://api.netatmo.com/oauth2/token',
clientId: 'cilentid',
clientSecret: 'cilentsecret',
scopes: ['read_presence'],
serviceConfiguration: {
registrationEndpoint: 'https://example.com'
}
}
如果不使用,您可以尝试其他方法。
您尝试并按照此链接上的型号npm install react-native-app-auth --save
按照安装说明进行操作。
在此之前,您必须退出世博会。跑expo eject
例子
import { authorize } from 'react-native-app-auth';
const config = {
issuer: 'https://api.netatmo.com/oauth2/token',
clientId: 'cilentid',
redirectUrl: 'https://api.netatmo.com/',
scopes: ['read_presence'],
clientSecret: 'cilentsecret'
};
const result = await authorize(config);
推荐阅读
- php - 如何在 wordpress 中使用带有联系表 7 的 mailjet
- python - 测试布尔变量
- c++ - 如何在 C++ 中获取自动变量的类型
- python - 使用python抓取html元素的内部标签时出错
- mysql - MySql:按日期计算值的出现次数
- mysql - 从 Spring Boot 获取 MySQL thread_id
- javascript - React Native - 根据动态状态获取json的值
- c++ - 名称包含“.”的 ptree get_value
- javascript - functions.js:1 Uncaught SyntaxError: Unexpected token {
- javascript - 当有人右键单击并选择上下文菜单时,找到我的光标所在的 tr