Я установил response-native-linkedin npm в своем приложении и создал приложение в учетной записи разработчика developerWorks. Теперь я могу войти в свое приложение с помощью входа в систему linkedin, но я также хочу реализовать выход из системы linkedin. Как этого добиться ?.Здесь я нигде не храню токен локально.Мой пример кода:
render(){
return(
<View>
<LinkedInModal
ref={ref => {
this.modal = ref
}}
clientID="xxxxxxxxx"
clientSecret="xxxxxxxxx"
redirectUri="xxxxxxxxxx"
onSuccess={(token) => {
console.log("getting token",token);
this.getLinkedInUser(token)
}}
onError={(error)=>{
console.log("onError",JSON.stringify(error))
alert('LinkedIn Login is Cancelled ');
}}
linkText={null}
/>
<TouchableOpacity style={styles.LinkedInStyle} activeOpacity={0.5}
onPress={()=>{
console.log("linkedin login is first
time",this.state.linkedInFirstTime);
this.modal.open()
}
}>
</View>
)
}
getLinkedInUser=async ({ access_token })=> {
try{
console.log("inside getLinkedInUser",access_token ) ;
this.setState({ refreshing: true })
const baseApi = 'https://api.linkedin.com/v1/people/'
const qs = { format: 'json' }
const params = [
'first-name',
'last-name',
'picture-urls::(original)',
'headline',
'email-address',
'id'
]
fetch(`${baseApi}~:(${params.join(',')})?format=json`, {
method: 'GET',
headers: {
Authorization: 'Bearer ' + access_token,
},
})
.then(async (response)=>response.json())
.then(async (payload)=>{
console.log("inside payload");
this.props.storeData(payload , "linkedin");
})
.catch((error)=>{
console.log("error while fetching",JSON.stringify(error.message));
})
}
catch(error){
console.log("error",error.message);
}
}