Connecting to Identity Server 3.0 from React Native
I am working on a react native project and need to connects to a self hosted Identity Server (Oauth 2.0).
I created a custom provider for Identity Server and add that to the provider, However, when the sign in button is clicked, it ran into the error block of authorize.
Here is the code on the sign in screen:
const oauthManager = new OAuthManager('KaizenApp')
oauthManager.addProvider({
'kaizenAuth': {
auth_version: '2.0',
authorize_url: 'https://idserver.com/connect/authorize',
access_token_url: 'https://idserver.pplguard.com/connect/token',
callback_url: ({app_name}) => ${app_name}://oauth,
}
});
oauthManager.configure({ kaizenAuth: { client_id: 'implicitclient', response_type: 'id_token token', } });
export default class LoginScreen extends React.Component { static navigationOptions = { header: null };
onSignIn(){
oauthManager.authorize('kaizenAuth', {scopes: 'openid profile email api roles'})
.then(resp => {
alert('Your users ID')
})
.catch(err => alert('There was an error'));
}
render() {
const { navigate } = this.props.navigation;
return (
<View style={styles.container}>
<View style={styles.body}>
<Image
resizeMode= 'contain'
style={{width: 160}}
source={require('../images/logo.png')}
/>
</View>
<View style={styles.footer}>
<TouchableHighlight style={styles.signInButton} onPress={() => this.onSignIn()}>
<Text style={styles.signInButtonText}>Sign In</Text>
</TouchableHighlight>
</View>
</View>
);
}
}