I am using graphcool with auth0 integration. I wou...
# prisma-whats-new
p
I am using graphcool with auth0 integration. I would like to migrate some users from our db into the graphcool db but for that I'd first need to create a auth0 account for each user right? Do I then need to use the createUser mutation with a
idToken
(that needs to be generated via auth0 auth api) or what? Is there no simpler way to do this?
@agartha @nilan
just tagging you guys in case you dont see this between all the other messages 🙂
a
Are you using the built-in auth0 integration, or the custom one?
p
built in
please tag me in replies as slack doesnt seem to notify me if I close this slack community and switch to another
In case it does the same for you, tagging you too 😛 @agartha
p
@Pieter I'm struggling with similar case. I don't migrate users, but when creating new User in graphcool I need auth0 idToken of newly created auth0-user (which is created by Graphcool function) I don't know how to obtain such token. Maybe you know how?
a
@Pieter @panzupa I don't think the built-in authentication is sufficient for your usecase.
p
@agartha I get it. The workaround would be too have this idToken from auth0. I just don't know whether it's possible to fetch one from serverless function. This is more on auth0 side
p
@agartha@panzupa how would I go about making it custom? Do I need to implement my own resolvers for it? Is there no way to create a graphcool user via some api command without the need to specify the idToken but rather just the auth0 ID?
a
@Pieter With the built-in integration, that's not possible no. So you'll need your own resolvers if you want to go in that direction. Maybe you can wrap the
createUser
call in a single resolver function that would be called when a user signs in using Auth0, but I don't have a ready-made solution.
p
Where do I read up on how to do that? I haven't really started with custom resolvers yet
a
The docs are a bit in flux at the moment, I think you can get the right pointers from @nilan
p
But I guess you would need to switch to new framework to use them
a
No, you can also use resolver functions in the console
p
Ok, thanks
@nilan can you point me and @Pieter to an example of resolver function that saves data into database? Basically we want to have another
createUser
function that accepts auth0userId and not authProvider field.
p
yeah that would be amazing @nilan
@agartha we both still struiggling with this. We've managed to get a idToken from auth0 and want to call the standard createUser mutation with the standard integration, but it's not working. See my latest comment in this forum post: https://www.graph.cool/forum/t/how-to-create-a-new-auth0-authenticated-user-in-graphql/757/14
@agartha thanks for your reply there. I sort of found the issue
Basically we using different clientIds for the web app and the server, which seems to be required as auth0 doesnt seem to support HS256 for web apps
@jmanke where did you remove the audience?
a
Huh? No, you have to specify the same clientid in the Graphcool Auth0 configuration, otherwise it will not work
p
yes I realized that
but its a Single page application (react) that is talking to graphcool via apollo
and SPA clients dont allow hs256 tokens
So Graphcool will need to accept RS256 if we want to do it that way. The only alternative is to set the SPA to a private api which will require me to host the secret in the UI code which would be very bad
@agartha you following? Please do let me know if I am not making sense
a
If you enable OIDC, it forces RS256. That's what the forum post is about.
p
yes, but its not enabled
auth0 enforces it regardless of whether I enable it or not because its a public app (run in the browser)
n
the legacy Auth0 integration was not designed for this use case - please implement your own integration using a resolver function