I am trying to use Auth0 in a firebase function. This was working in the past, but it stopped working and I’m having a hard time tracking down what changed. I’m getting this error:
Error getting userProfile from Auth0: Error: Argument “documentPath” is not a valid ResourcePath
I don’t have an argument “documentPath”, so I’m guessing it is part of the auth0 npm package.
// Initialize the Auth0 client
var AuthenticationClient = require('auth0').AuthenticationClient;
var auth0 = new AuthenticationClient({
domain: 'familybank.auth0.com',
clientID: '5u-KHjbCzIpTTAxf7C1Hw6SfTePDOVh0'
});
Then I use it like this
let accessToken = app.getUser().accessToken
auth0.getProfile(accessToken).then( function (userInfo) {
return userInfo;
}).then( function(userInfo) {
// do stuff with userInfo
}
I think the error is happening when I call getProfile. I have confirmed that I can get the access token properly and it is valid based on the logs in my auth0 dashboard.
I updated the code as follows, but I’m not sure how to make sense of the response
When I log the userInfo object above, I get the following
{"https://access.control/roles":["user","admin"]}
I’m not sure why that isn’t a userProfile, like you show. By the way, it was working before, just as you show. I’m still scratching my head. Hoping you can help me figure out what happened.
So, I did a little more searching and I think this is related to Rules. I did create a rule a long time ago for the user that produces this response. I tried disabling that rule, but now all I get is an empty document {}.
Is there some way to get back to a normal response?
It’s quite a rare situation to be honest. The only thing that comes to my mind is that the reason for an empty payload in / userinfo is usually caused by not including the openid scope in the initial request.
I finally understood that you mean to add the actual word “openid” to the scopes. I had to go through and create a new Application from scratch and make sure all the reply URLs and other values were right. I now have it working.
I’m using this with Firebase functions and Dialogflow, so I had to use async/await to let the authentication and getProfile complete so the function didn’t return before the promise was fulfilled.
Great @dwmaillist! Glad that you finally made it! Sorry that you weren’t able to find it in the docs or we didn’t communicate it enough clearly. Thanks a lot for sharing with community!
I think part of what made this tricky is that “openid” needed to be added to my Actions on Google settings for the project I was integrating with Auth0. This was also working about 9 months ago, and then stopped working, which suggests that Auth0 made a change and I either missed a needed communication or one wasn’t sent.
Nearly all of what I needed was available online, but not in one place and I had to clean up some mess that I ended up with in my Auth0 dashboard to really know what was going on.
That’s actually very constructive feedback. We constantly work on making our docs more relevant, easy to understand but also easy to navigate especially in terms of being forced to grasp more and more complex identity concepts. We’ll take that into account!