Search code examples
amazon-web-servicesnativescript-angularaws-amplify

Manually set current user credentials in AWS Appsync


I'm using Nativescript with AWS Amplify to login to AWS AppSync.

The session stored by Amplify is cleared after app refresh. I get no user from Auth.currentSession() after app refresh.

However, I store the jwt from login and can access endpoints manually by passing that in header. I would like to use this to make Amplify believe that a user is logged in to use it in other parts of the application.

Is there a way to manually set credentials to use all the functionality of Amplify?

And how is successful login handled? How can I emulate the behaviour after successful login to set current session credentials manually?


Solution

  • There is no possible way to this this as of now, however according to this and this issue on github, they have acknowledged this as a feature-request and are probably working on this.

    The solution to my problem was to use the nativescript-localstorage module and assign global["storage"] to this module.

    import * as storage from "nativescript-localstorage"
    global["storage"] = storage;