https://supertokens.com/ logo
#support-questions
Title
# support-questions
k

Kharann

04/12/2022, 11:59 AM
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

nkshah2

04/12/2022, 12:03 PM
You could use a JWT to authenticate users on Apollo Studio: https://supertokens.com/docs/emailpassword/common-customizations/sessions/with-jwt/about
k

Kharann

04/12/2022, 12:03 PM
Yeah I think i will go for the JWT then!
its juts that i saw that apollo studio had support for setting cookies
n

nkshah2

04/12/2022, 12:04 PM
What part did not work for you?
Were you getting any specific errors?
k

Kharann

04/12/2022, 12:05 PM
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

nkshah2

04/12/2022, 12:09 PM
= If you have please follow this trouble shooting guide and post your output here (https://supertokens.com/docs/emailpassword/troubleshooting/how-to-troubleshoot)
k

Kharann

04/12/2022, 12:10 PM
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

nkshah2

04/12/2022, 12:12 PM
So if you already called signIn/signUp from SuperTokens you dont need to call createSession yourself
k

Kharann

04/12/2022, 12:18 PM
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

nkshah2

04/12/2022, 12:19 PM
You can use
supertokens-website
on the frontend to help with this. It uses network interception and does session management for you
k

Kharann

04/12/2022, 12:19 PM
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

nkshah2

04/12/2022, 12:20 PM
So the backend SDK (that you are using) already sets the cookies
The browser should handle sending them
k

Kharann

04/12/2022, 12:21 PM
aaah, that makes sense
It seems difficult to set them in an external grahql playground
so JWt is probably the easiest solution
n

nkshah2

04/12/2022, 12:22 PM
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