[Error: ExpoAppAuth.Get Auth: JSON deserialization error]

穿精又带淫゛_ 提交于 2019-12-11 15:20:50

问题


Getting an error using AppAuth from 'expo-app-auth';

When i try to authi get the following error: [Error: ExpoAppAuth.Get Auth: JSON deserialization error]

const config =  {   

  serviceConfiguration: {

  authorizationEndpoint: 'https://api.netatmo.com/oauth2/authorize',

  tokenEndpoint: 'https://api.netatmo.com/oauth2/token',
  },

  clientId: 'cilentid',

  clientSecret: 'cilentsecret',

  scopes: ['read_presence']

}

Is it something with the config?


回答1:


Your config is not valid.

This is related to the issue at https://github.com/expo/expo/pull/5311 - there is an error in a ternary operator in expo-app-auth which will get rolled into an upcoming release. In the meantime, you must specify a dummy value for registrationEndpoint in your service configuration object.

const config =  {   

  issuer: 'https://api.netatmo.com/oauth2/token',

  clientId: 'cilentid',

  clientSecret: 'cilentsecret',

  scopes: ['read_presence'],

  serviceConfiguration: {
        registrationEndpoint: 'https://example.com'
      }

}

If this is not used, you can try another method.

You try npm install react-native-app-auth --save And follow the installation instructions according to the model at this link.

Before that, you have to eject the Expo. run expo eject

Example

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);


来源:https://stackoverflow.com/questions/58732129/error-expoappauth-get-auth-json-deserialization-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!