2 Answers
- Newest
- Most votes
- Most comments
2
Hi Navin,
You should just call Auth.currentSession() method, as Amplify will handle that, see this: https://docs.amplify.aws/lib/auth/manageusers/q/platform/js/#retrieve-current-session
Hope it helps and appreciated an accepted answer if so, so that benefits community when searching for similar issues, cheers!
0
in amplify gen 2 you can retrieve a new token by calling fetchAuthSession
i am using angular (with typescript) so you probably have to adapt to your needs.
import {fetchAuthSession} from "@aws-amplify/auth";
const authSession = await fetchAuthSession({forceRefresh: true});
and recreate your client
import {generateClient} from "@aws-amplify/api";
import type {Schema} from "../../../amplify/data/resource";
const accessToken = authSession?.tokens?.accessToken
const options = !!accessToken ? {authToken: accessToken?.toString()} : {}
const client = generateClient<Schema>(options)
answered 2 years ago
Relevant content
- asked 2 years ago
- asked 2 years ago
- asked 3 years ago
- AWS OFFICIALUpdated 16 days ago
- AWS OFFICIALUpdated 4 years ago

in gen 1 v 6 we cannot access refresh token from session. So how can we programmatically log out an user from sso ?