Hey, is there any way where i can transfer authTo...
# ask-a-descoper
u
Hey, is there any way where i can transfer authToken returned from descope webflow in flutter to flutter webview where my web app is running there i want to use that token, if I try to transfer token from session token it gives error
Converting object to an encodable object failed: Instance of DescopeSession
, i want to utilize the native features of mobile app like biometric, also my app is running in webview (react app), is there is any to achieve that?
Current errors
r
Hi @Uday Singh Let me check your issue
Yes, you can transfer the auth token from Descope Flutter to your WebView. The error you're seeing happens because you're trying to pass the entire
DescopeSession
object instead of just the JWT string. Solution: Extract the session JWT from the Descope session and pass it to your WebView:
Copy code
final sessionJwt = Descope.sessionManager.session?.sessionJwt;
if (sessionJwt != null) {
    // Pass sessionJwt to your WebView
}
For your React app in the WebView: Once you have the
sessionJwt
, you can inject it into your WebView using JavaScript channels or by appending it as a URL parameter/header when loading your web app. Your React app can then use this token for API requests. Using native biometric authentication: You can authenticate users with passkeys (which leverage biometric authentication) in your Flutter app, then pass the resulting session token to your WebView:
Copy code
final authResponse = await Descope.flow.start(options);
final session = DescopeSession.fromAuthenticationResponse(authResponse);
Descope.sessionManager.manageSession(session);

// Extract and pass the JWT
final sessionJwt = session.sessionJwt;
Your React app can then use this token by setting it in request headers for backend authentication. Reference doc: https://github.com/descope/descope-flutter/blob/main/README.md https://docs.descope.com/getting-started/flutter/go
u
in react app i want to use that method
Copy code
const { isAuthenticated, isSessionLoading, sessionToken, claims } = useSession();
  // useUser retrieves the logged in user information
  const { user, isUserLoading } = useUser();
like is isAuthenticated should be true, session token should return the token and user should return user details, isUserLoading should return false
i mean i want to utilize the hooks
@Rahul Rijhwani thanks for answering above, is there way where i can use hooks
r
In react app you can use that methods in webview pages check this doc how to integrate descope in react app : https://github.com/descope/descope-js/blob/main/packages/sdks/react-sdk/README.md
u
@Rahul Rijhwani yes i can use, but this will not give details of user which i logged to flutter mobile app, i want details of that user. mobile app -> webflow -> webview(react app) (here i want hooks which should returned the user which logged in through mobile app)
session.sessionJwt
will expire by some time? after some time i've to reshare the token to webview, i want to share only at one time at time of running the webflow after, i want to use
Copy code
const {sessionToken } = useSession();
maybe setting cookies same as mobile app will help? or there is other way?
r
Can we setup call @Uday Singh ?
u
at 7? invite shared
r
Sure let's connect at 7
u
@Rahul Rijhwani as we discussed points in meet yesterday, can we expect the solution by 7PM and schedule the meet for same
r
Hey @Uday Singh I am checking with my internal team will be get back to you by today
u
Thanks @Rahul Rijhwani , waiting for update
r
Hi @Uday Singh I had discussed with internal team as of now for your scenario you need to use restful apis for accessing use information or any other descope feature using https://docs.descope.com/api from reactjs app. I am adding @Michael Rimboim. @Michael Rimboim once you have further details, Please push the update here.
u
@Rahul Rijhwani please find the doc there i noted down the requirement along with approaches
r
Let me check with team and I'll get back to you
Hello @Uday Singh I discussed with team They are suggested please integrate login in react js app only. for more clarity added @Itai Hanski here.
i
While technically this may be possible, it is certainly not recommended. Each SDK is built around both acquiring a session, i.e. logging in, and also managing that session. Separating these aspects into completely different SDKs is not advised and my lead to unwanted edge cases. Since you say your application is built with react and displayed in a WebView, the best approach in this case would be to use the Descope React SDK to handle authentication and session management.
u
Hey @Rahul Rijhwani can we connect on 12:15PM i've few queries
with your assistance it will resolve quickly
r
Sure @Uday Singh let’s connect at 1:30