I want to call the authorization extension API from a rule in order to obtain the full group details for a user (ie. including the groups description)
I took the code from the rule that’s generated by the extension, and made a new rule that executes the following query:
// Get the groups for the user.
function getUserGroups(user, context, cb) {
request.get({
url: EXTENSION_URL + "/api/users/" + user.user_id + "/groups",
headers: {
"x-api-key": "94ec..."
},
timeout: 5000
}, cb);
}
But the request fails with a missing authentication
error:
12:35:41 PM: 180220/113541.054, [log,error] data: Request: GET /api/users/auth0%7C5968d1...7c6feca7/groups
12:35:41 PM: 180220/113541.055, [log,error] data: Response: {
"data": null,
"isBoom": true,
"isServer": false,
"output": {
"statusCode": 401,
"payload": {
"statusCode": 401,
"error": "Unauthorized",
"message": "Missing authentication"
},
"headers": {
"WWW-Authenticate": "Token"
}
}
}
Should the x-api-key token also work for this endpoint, or do I need to make a request to /oauth/token
to get my own access_token each time?