Too few arguments to function Skeleton\\Domain\\Token:
timogoosen opened this issue · 3 comments
timogoosen commented
If I run any of the examples for example:
curl "https://192.168.50.52/todos" \
--request POST \
--include \
--insecure \
--header "Authorization: Bearer INSERT-JWT-TOKEN-HERE" \
--header "Content-Type: application/json" \
--data '{ "title": "Test the API", "order": 10 }'
Then I get this response
{
"title": "Too few arguments to function Skeleton\\Domain\\Token::__construct(), 0 passed in .../app/config/middleware.php on line 41 and exactly 1 expected",
"type": "about:blank",
"status": 500
}
I'm not sure what I'm doing wrong. I've tried everything including creating the database and adding tables and data for the todo's app.
Thanks
timogoosen commented
Think I solved my own issue. I changed this part in config/middleware.php:
...
$container["token"] = function ($container) {
return new Token;
};
...
To this instead:
...
$container["token"] = function ($container) {
return new Token([
"scope" => ["todo.read", "todo.write"]
]);
};
...
Which seemed to solve the issue.
timogoosen commented
Ok seems like todo.write is not a valid scope I just got that from what looks like one of the unit tests. I guess this is better:
// $valid_scopes = [
// "todo.create",
// "todo.read",
// "todo.update",
// "todo.delete",
// "todo.list",
// "todo.all"
// ];
$container["token"] = function ($container) {
return new Token([
"scope" => ["todo.create", "todo.read", "todo.update", "todo.delete", "todo.list", "todo.all"]
]);
};
tuupola commented
Thanks for the heads up! Not sure how I missed this.