【问题标题】:[Error: ExpoAppAuth.Get Auth: JSON deserialization error][Error: ExpoAppAuth.Get Auth: JSON deserialization error]
【发布时间】:2019-11-06 14:15:27
【问题描述】:

使用“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']

}

配置有问题吗?

【问题讨论】:

  • 你执行了什么功能?
  • 异步函数 signInAsync() { const authState = await AppAuth.authAsync(config) .catch((error, state) => console.log(error));返回身份验证状态; }
  • 它适用于 ios 顺便说一句。

标签: react-native expo appauth


【解决方案1】:

您的配置无效。

这与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 并按照the model at this link.的安装说明进行操作

在此之前,您必须退出世博会。运行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);

【讨论】:

  • 我试过它给了我“[错误:您必须提供 issuer 或同时提供 authorizationEndpointtokenEndpoint]”
  • 作为“发行人”怎么样?
  • 这不是真的它指的是一个端点作为错误消息。
  • 发行者:使用 https 方案的 URL,不包含 OP 声明为其发行者标识符的查询或片段组件
  • 这在 ios [错误:ERR_APP_AUTH: Non-200 HTTP response (404) fetching discovery document 'api.netatmo.com/oauth2/.well-known/openid-configuration'.]
猜你喜欢
  • 2017-07-12
  • 2021-11-26
  • 1970-01-01
  • 2013-05-27
  • 2022-12-01
  • 2022-12-27
  • 1970-01-01
  • 2012-07-28
  • 2021-03-13
相关资源
最近更新 更多