Npm Error: Argument "documentPath" is not a valid ResourcePath

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.

I’m using release 2.9.1.

Any ideas?

do you have any code snippets?

I initialize the auth0 object like this

// 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.

hmm. weird. this works for me:

Can you build an isolated repro so I can debug?

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?

I’ve been in to the API settings and checked every scope, but that doesn’t have any impact either.

I have also created a new application, but it doesn’t work. I get the exact same behavior.

I have created an isolated function to reproduce this that matches what you show. It never returns or errors out.

// Initialize the Auth0 client
var AuthenticationClient = require('auth0').AuthenticationClient;
var auth0 = new AuthenticationClient({
    domain:       'familybank.auth0.com',
    clientID:     '5u-KHjbCzIpTTAxf7C1Hw6SfTePDOVh0'
});

exports.auth0Only = functions.https.onRequest((request, response) => {
    console.log('Request headers: ' + JSON.stringify(request.headers));
    console.log('Request body: ' + JSON.stringify(request.body));
    console.log('accessToken: ' + request.body.accessToken);

    auth0.getProfile(request.body.accessToken).then( function (userInfo) {
        console.log(userInfo);
        return userInfo;
    }).then( function(userInfo) {
        console.log(userInfo);
    });
});

I think make a call directly to this as follows

curl -H "content-type: application/json" --data "{\"accessToken\": \"sQJE7uqauXvNcf62liCCWBZPnSIlbuQG\"}" http://localhost:5000/familybank-51a57/us-central1/auth0Only

In the logs I see this

info: User function triggered, starting execution
info: Request headers: {"content-length":"51","content-type":"application/json","accept":"*/*","user-agent":"curl/7.58.0","host":"localhost:5000","connection":"close"}
info: Request body: {"accessToken":"sQJE7uqauXvNcf62liCCWBZPnSIlbuQG"}
accessToken: sQJE7uqauXvNcf62liCCWBZPnSIlbuQG
info: {}
info: {}

Hey @dwmaillist!

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.

1 Like

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.

Thanks for the help.

1 Like

Thanks @dwmaillist!

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!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.