My decoded auth0 token doesn’t include the scope f...
# prisma-whats-new
a
My decoded auth0 token doesn’t include the scope field. Can anyone help?
Cannot read property ‘includes’ of undefined”
r
i seem to be stuck in a similar situation here
@alexanbj do you know how we can debug the js file in such a situation ?
console.log
doesnt seem to add logs for me in the graph.cool logs
a
it does for me
event.logs.stdout
r
event.logs.stdout
didnt understand this
how are you adding logs to the JS file and where are you able to see them ?
a
if I ‘console.log’ inside a graphcool function, then perform a query/mutation that triggers the function, then run ‘graphcool logs’, I’ll see the things I logged in the event
r
doesnt work for me somehow 😞
i am running this locally
a
so am I
r
i just keep getting this whatever i do :
Copy code
2017-11-20T08:31:23.597Z 2308ms FAILURE {
                                                                                                                      │  "error": "Function returned invalid status code: 0. Raw body: {\"logs\":[{\"stdout\":\"\"},{\"stderr\":\"\"},{\"err
                                                                                                                      │or\":\"No content to map due to end-of-input\\n at [Source: ; line: 1, column: 0]\"}],\"response\":{\"error\":\"Funct
                                                                                                                      │ion did not return a valid response. Check your function code / logs.\"}}"
                                                                                                                      │}
can you make sense of this ?
a
Sorry, I haven’t seen something like that before
n
@rhishikeshj, what's your graphcool version?
r
@nilan
graphcool/0.8.1 (darwin-x64) node-v8.6.0
i was getting this error because i was returning a string from a function where a promise was expected. Not a JS developer so didnt realise this
n
interesting, could you PM me your function that lead to this error?
r
@alexanbj I was able to get this working finally ! so the pain points for me were : I was using the idToken returned by auth0 instead of the accessToken. I wasnt using the accessToken since it was an opaque string format and not JWT. Got the JWT version of the accesstoken from auth0 by setting the
audience
string in my config. then i had to modify the fetchAuth0Email function and change it to return name and email since my types.graphql needed name to create a user.
a
@rhishikeshj nice!
The accessToken is working for me
The only thing is that it doesn’t have any scope property
I’m not setting audience though. Wonder if that could be the problem
r
i think it might be the problem
you can try and decode your JWT token here : https://jwt.io/
a
yup, I can decode it fine
but no scope property
do you have a “scope” in your decoded token?
r
Yes, after i followed all of the above changes i was able to get a scope too. Btw, just to confirm, your oauth2 client is also providing the correct scopes right ?
a
in the auth0 dashboard?
or in the client code
r
Scopes in the client code
I had openid email and offline_access
In the scopes
a
Got it working now 😄