I have an application that shares backend with a web. This application has basic email/password login that returns Access Token which is being sent as a header for any other requests. The application also has a screen that is a WebView which displays the web version of this app.
My problem is that I don't know how to share user session between RN app and the WebView. When the user logs in the application it should also log him in the WebView page and if the user logs out it should log him out the WebView aswell.
Is there any way, to inform the WebView that user has logged in and that he should be logged in in the WebView as well?
I tried sending the Authorization header in the WebView source but it doesn't work. https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md#working-with-custom-headers-sessions-and-cookies
Any auth is based on a secret. First, you need to decide what is your secret, it can be a session identifier or jwt token. Then you can communicate between React Native -> Web and back Web -> React Native
follow this guide communicating-between-js-and-native and share your knowledge about this secret and use it for your requests.
Related to custom headers this will set the header on the first load, but not on subsequent page navigations.
Related
In my react app i added a button that redirects to the login page url. In my backend login page i used passport.js to make discord oauth and then redirect to an callback page where i have a simple rendered page who said is logged in successfuly, now he can return to the app. After that, in my frontend i added a button where it sends a axios post request with credentials and it says its unauthorized, so in few steps i need to use the same cookie from the web page i logged and need to access that from my react app.
BTW. i already use cors in my backend and i watched some tutorials but cant find a solution for that. Thanks in advice
I'm using `
https://api.instagram.com/oauth/authorize?client_id={{ instagramAppId }}&redirect_uri={{ redirectUrl }}&scope=user_media,user_profile&response_type=code
` url to verify user via instagram api.
Is it possible to get access token from instagram mobile app? The web view with insta login needs credentials to login, even though user is logged in mobile app.
Thanks!
Webviews keep their own cookie jars, so you have to log in separately. You can't use the mobile app's tokens. You can open the login page in a browser instead of a web view. Then, if the user is already logged in to Instagram in this given browser, you will instantly get a response from the authorization endpoint. Still, the user needs to be logged in in the concrete browser, being logged in in the app won't help.
I am new in react native,
I have integrated "WebView" for user login in my app so, hear i have need only login response like user is authenticate or not without post any parameters or message, authentication is handle by that particular site so its not in my hand and i can't change any thing so it is possible for app login.
If yes then how can i get response in "onMessage" in my webview?
App Flow:
- Splash screen
- Login screen (Webview)
- If user authenticate then redirect on dashboard
I have used "react-native-webview"
npm
Thanks in advance
I am trying to build an SSO login flow on a React Native app using Okta's oauth 2.0 api.
Here is the flow that I am trying to achieve:
(1) webview renders login page from /oauth2/:authorizationServerId/v1/authorize?response_type=code&response_mode=query&client_id=&scope=&redirect_uri=___.
(2) user logs in.
(3) webview renders redirect_uri with authorization code in url.
(4) I extract authorization code and send it along with client id, client secret, and other necessary params to /oauth2/:authorizationServerId/v1/token.
(5) endpoint responds with accessToken.
I am able to get the accessToken through this process using postman and curl so I know that this works. I have also verified that this exact flow works on a Xamarin app.
However, when trying to hit the /oauth2/:authorizationServerId/v1/token route from my React Native app after getting the authorization code, I always get a 403 without an error message.
I am using fetch for my api calls and used the not-CRNA way of creating my app.
Has anyone ever come across this issue before? In general, has anyone been able to get this type of Okta flow to work with React Native?
At first I thought it was a CORS issue but followed the CORS test here and verified that this was not the case.
I also thought it was an issue with making a fetch request and rendering a webview at the same time. I built my own Okta sign-in page so I wouldn't have to use a webview and used this flow but got the same 403.
Any and all help on this would be greatly appreciated.
Thanks!
As per title in my app i can successfully login with facebook or google account as per tutorial given in developer.facebook.com and developer.google.com but problem is that flows not return from browser to my app.
Did you configure your project's URL Schemes correctly in your info plist?
https://developers.facebook.com/docs/ios/getting-started#configure
The login calls a custom URL that your app has to handle after the authentication is done