Auth0 Home Blog Docs

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

npm

#1

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?


#2

do you have any code snippets?


#3

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.


#4

hmm. weird. this works for me:

Can you build an isolated repro so I can debug?


#5

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.


#6

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?


#7

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.


#8

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: {}

#9

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.