问题
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