How to cache user profile data

Just started using Okta and have implemented a login flow for my Angular SPA which all works great. However how do I intercept the login flow to enable me to grab the users name and email address so that I can cache this information for use when the app is offline?

Currently the flow redirects back to the OktaCallbackComponent which handles the parsing of the request, I do not specifically want to be concerned with this parsing hence don’t want to direct to my own component, or is this the only way?

I am now trying to subscribe to the $authenticationState observable, however when I call.getUser() inside that event the page seems to refresh and the code terminates?

OK I clearly have something triggering too early, if I take the subscription aspect away everything is working.

I’ll investigate further!