Token Auth not automatically getting stored as a cookie
How is the login supposed to work? Because when I call loginUser, I get a response with a token but I don't get a cookie back.
7 Replies
Hello @Ian
After a successful
manifest.login()
function, the token is automatically attached to the headers of the requests until you manfinest.logout()
.
This means that you can simply:
However if you need the token for some reason (store in local storage for example) , since the SDK version 1.2.2
you can:
Now that I have a cookie with my token, how can I try to use it for the SDK so that the user doesn’t have to log in again?
If I were using regular HTTP requests I could just attach it to the Authorization header, but how to do it using the SDK? @brunobuddy
Seems there's no way to do it now, while the solution could be as simple as to provide the option to pass a custom token while creating a new Manifest SDK instance, such as:
or, alternatively (might be a safer option), provide a separate method like:
Let's discuss the possibilities and if needed I could try to make a PR.
Hello @lugshar, if you use the manifest SDK as singleton in a service, it should take the token in the requests once the login has been sucessful in theory. What front-end stack are you using ? I can try to create an example repo
It does work, my question is about a different use case – let’s call it “don’t log me out” upon logging in.
ah you mean from session to session ?
Yep
It's not that I'm greatly blocked by it, but definitely that's a feature I consider a must have, otherwise it's a pain in the ass to have to log in each time.
Again, I could try making a PR with that, just want to have a confirmation that I am right in my assumptions. I did take a look at the source code and did not find anything, but I did find quite a few low-level methods that could be used to implement this kind of functionality easily.
Hello @lugshar it is definitely something that we would like to have, feel free to create a PR if you want. Make sure that you read the contributing file https://github.com/mnfst/manifest/blob/master/CONTRIBUTING.md
GitHub
manifest/CONTRIBUTING.md at master · mnfst/manifest
Portable backend to ship fast. Contribute to mnfst/manifest development by creating an account on GitHub.