I am learning React-Native and trying to do oAuth2 authentication. I have registered my app with the service and my redirect uri. When the user clicks on the "login' button on the app, it is supposed to do the following:
onLoginPressed() {
fetch("https://www.hackerschool.com/oauth/authorize?response_type=code&client_id=("+auth.client_id+")&redirect_uri=("+auth.redirect_uri+")")
.then(response => _handleResponse(response))
.catch(error =>
this.setState({
isLoading: false,
message: 'Something bad happened ' + error
}));
LinkingIOS.openURL("https://www.hackerschool.com/oauth/authorize?response_type=code&client_id=("+auth.client_id+")&redirect_uri=("+auth.redirect_uri+")");
}
However, the response is the complete html render instead of the token that bounces me back to my redirect_uri which is my app.
Any ideas as to what I am doing wrong?
One thing to check is that Xcode is searching the library headers properly (especially with LinkingIOS).
"This step is not necessary for libraries that we ship with React Native with the exception of PushNotificationIOS
and LinkingIOS
."
Is the LinkingIOS.openURL
function supposed to run after a response from the server in the fetch
block? If so, then you'll want to include it in a another then
block.
As it is written now, LinkingIOS.openURL
will run right after the fetch
line. Then, as they resolve or error out, the then
and catch
blocks of fetch
will run.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.