Is there a way to authenticate programaticaly. I'm...
# support-questions
k
Is there a way to authenticate programaticaly. I'm using the Email Password and Session recipe. I want to authenticate on https://studio.apollographql.com so that i can have a playground for my developers. My initial thoughts were to use
EmailPassword.signIn
and
Session.createSession
to save valid auth tokens as cookies on the graphql playground. The idea was to use a login mutation which sets the cookies, but i cant seem to get it to work programatically
I've been thinking of just enabling JWT. The important part is just to get Apollo studio to work. I could enable Apollo Playground so that it's on the same domain, but playground will be deprecated and therefore using apollo studio would be preferable
n
You could use a JWT to authenticate users on Apollo Studio: https://supertokens.com/docs/emailpassword/common-customizations/sessions/with-jwt/about
k
Yeah I think i will go for the JWT then!
its juts that i saw that apollo studio had support for setting cookies
n
What part did not work for you?
Were you getting any specific errors?
k
I did get the user from the signIn method
but when trying to create a new session I would get an error
The signIn method worked well and i got a user out from it
But when creating a session and passing in the res object, it wouldn't work
This is the settings in apollo studio which lead me to attempt session authentication in apollo studio haha. After setting the correct settings it did lead me down a rabbithole
n
= If you have please follow this trouble shooting guide and post your output here (https://supertokens.com/docs/emailpassword/troubleshooting/how-to-troubleshoot)
k
yes, I did set it up correctly and I do get correct output when making a graphql request from the frontend
It's just when using an apollostudio
Did I use createSession correct? I was unsure how to create sessions programatically and attach them to cookies
n
So if you already called signIn/signUp from SuperTokens you dont need to call createSession yourself
k
Which methods would I need to use to attach the new session to the response/request?
I'm looking through the recipe_session documentation right now
n
You can use
supertokens-website
on the frontend to help with this. It uses network interception and does session management for you
k
Hmm, that would be hard to implement in apollo studio
Well, might as well go for JWT then
thanks for the help :))
it was worth the attempt
n
So the backend SDK (that you are using) already sets the cookies
The browser should handle sending them
k
aaah, that makes sense
It seems difficult to set them in an external grahql playground
so JWt is probably the easiest solution
n
If you are successfully creating a session on Apollo Studio using SuperTokens then the part of sending cookies when making network requests should already be working
4 Views