joselfonseca / lighthouse-graphql-passport-auth Goto Github PK
View Code? Open in Web Editor NEWAdd GraphQL mutations to get tokens from passport for https://lighthouse-php.com/
Home Page: https://lighthouse-php-auth.com/
License: MIT License
Add GraphQL mutations to get tokens from passport for https://lighthouse-php.com/
Home Page: https://lighthouse-php-auth.com/
License: MIT License
Hi,
This error is showing up in the Laravel.log file after a fresh install of the package:
Undefined index: Mutation {"exception":"[object] (ErrorException(code: 0): Undefined index:
Mutation at /Users/.../vendor/nuwave/lighthouse/src/Schema/AST/ASTBuilder.php:148)
Using:
"joselfonseca/lighthouse-graphql-passport-auth": "^1.4",
"mll-lab/laravel-graphql-playground": "^1.1",
"nuwave/lighthouse": "^4.2"
Am I missing something?
IF the default guard is something else than web, the following issue appears
"Method Illuminate\\Auth\\RequestGuard::once does not exist."
This means I can't rely on Auth::once to get the user for the login response.
Hi,
First of all, thank you for this package, it's very helpful.
I've tried to use the social login GQL query as mentioned in the documentation.
https://lighthouse-passport-auth.web.app/docs/default-schema/
But I've got this error:
"message": "Method Illuminate\\Auth\\RequestGuard::onceUsingId does not exist."
at: HasSocialLogin.php > Auth::onceUsingId($user->id)
I found that it would work with Auth::guard('web')->onceUsingId($user->id)
but then it would not sync with SocialLogin@solve
because it's still using the default guard (API).
This is a preview of the api middlewares used:
protected $middlewareGroups = [
...
'api' => [
'throttle:60,1',
'bindings',
\Barryvdh\Cors\HandleCors::class,
\App\Http\Middleware\UseApiAuthGuard::class,
],
];
I may doing it wrong. I would appreciate some guidance if it were the case.
Thank you in advance
Any chance the composer file can get updated so this framework works with Laravel 7?
After setting up everything, when trying to login i am getting following errors.
{ "errors": [ { "message": "An unknown error occurred.", "extensions": { "guards": [], "category": "authentication" }, "locations": [ { "line": 2, "column": 3 } ], "path": [ "login" ], "trace": [ { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\joselfonseca\\lighthouse-graphql-passport-auth\\src\\GraphQL\\Mutations\\Login.php", "line": 21, "call": "Joselfonseca\\LighthouseGraphQLPassport\\GraphQL\\Mutations\\BaseAuthResolver::makeRequest(array(5))" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\nuwave\\lighthouse\\src\\Schema\\Directives\\FieldDirective.php", "line": 68, "call": "Joselfonseca\\LighthouseGraphQLPassport\\GraphQL\\Mutations\\Login::resolve(null, array(3), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\nuwave\\lighthouse\\src\\Schema\\Factories\\FieldFactory.php", "line": 225, "call": "Nuwave\\Lighthouse\\Schema\\Directives\\FieldDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}(null, array(2), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php", "line": 632, "call": "Nuwave\\Lighthouse\\Schema\\Factories\\FieldFactory::Nuwave\\Lighthouse\\Schema\\Factories\\{closure}(null, array(1), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php", "line": 555, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, instance of Closure, null, instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php", "line": 478, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: Mutation, null, instance of ArrayObject(1), array(1))" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php", "line": 921, "call": "GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}(array(0), 'login')" }, { "call": "GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}(array(0), 'login')" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php", "line": 923, "function": "array_reduce(array(1), instance of Closure, array(0))" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php", "line": 494, "call": "GraphQL\\Executor\\ReferenceExecutor::promiseReduce(array(1), instance of Closure, array(0))" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php", "line": 256, "call": "GraphQL\\Executor\\ReferenceExecutor::executeFieldsSerially(GraphQLType: Mutation, null, array(0), instance of ArrayObject(1))" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php", "line": 208, "call": "GraphQL\\Executor\\ReferenceExecutor::executeOperation(instance of GraphQL\\Language\\AST\\OperationDefinitionNode, null)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\webonyx\\graphql-php\\src\\Executor\\Executor.php", "line": 155, "call": "GraphQL\\Executor\\ReferenceExecutor::doExecute()" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\webonyx\\graphql-php\\src\\GraphQL.php", "line": 158, "call": "GraphQL\\Executor\\Executor::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, instance of GraphQL\\Language\\AST\\DocumentNode, null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\webonyx\\graphql-php\\src\\GraphQL.php", "line": 90, "call": "GraphQL\\GraphQL::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, 'mutation {\n login(input: {username: \"[email protected]\", password: \"9771767747\"}) {\n access_token\n refresh_token\n expires_in\n token_type\n user {\n id\n email\n name\n created_at\n updated_at\n }\n }\n}', null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null, array(29))" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php", "line": 177, "call": "GraphQL\\GraphQL::executeQuery(instance of GraphQL\\Type\\Schema, 'mutation {\n login(input: {username: \"[email protected]\", password: \"9771767747\"}) {\n access_token\n refresh_token\n expires_in\n token_type\n user {\n id\n email\n name\n created_at\n updated_at\n }\n }\n}', null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null, array(29))" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php", "line": 116, "call": "Nuwave\\Lighthouse\\GraphQL::executeQuery('mutation {\n login(input: {username: \"[email protected]\", password: \"9771767747\"}) {\n access_token\n refresh_token\n expires_in\n token_type\n user {\n id\n email\n name\n created_at\n updated_at\n }\n }\n}', instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\nuwave\\lighthouse\\src\\Support\\Http\\Controllers\\GraphQLController.php", "line": 70, "call": "Nuwave\\Lighthouse\\GraphQL::executeRequest(instance of Nuwave\\Lighthouse\\Execution\\LighthouseRequest)" }, { "call": "Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController::query(instance of Nuwave\\Lighthouse\\Execution\\LighthouseRequest)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php", "line": 54, "function": "call_user_func_array(array(2), array(1))" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php", "line": 45, "call": "Illuminate\\Routing\\Controller::callAction('query', array(1))" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php", "line": 219, "call": "Illuminate\\Routing\\ControllerDispatcher::dispatch(instance of Illuminate\\Routing\\Route, instance of Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController, 'query')" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php", "line": 176, "call": "Illuminate\\Routing\\Route::runController()" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", "line": 680, "call": "Illuminate\\Routing\\Route::run()" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", "line": 30, "call": "Illuminate\\Routing\\Router::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\nuwave\\lighthouse\\src\\Support\\Http\\Middleware\\AcceptJson.php", "line": 30, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 163, "call": "Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AcceptJson::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 104, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", "line": 682, "call": "Illuminate\\Pipeline\\Pipeline::then(instance of Closure)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", "line": 657, "call": "Illuminate\\Routing\\Router::runRouteWithinStack(instance of Illuminate\\Routing\\Route, instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", "line": 623, "call": "Illuminate\\Routing\\Router::runRoute(instance of Illuminate\\Http\\Request, instance of Illuminate\\Routing\\Route)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", "line": 612, "call": "Illuminate\\Routing\\Router::dispatchToRoute(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php", "line": 176, "call": "Illuminate\\Routing\\Router::dispatch(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", "line": 30, "call": "Illuminate\\Foundation\\Http\\Kernel::Illuminate\\Foundation\\Http\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\fideloper\\proxy\\src\\TrustProxies.php", "line": 57, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 163, "call": "Fideloper\\Proxy\\TrustProxies::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php", "line": 21, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php", "line": 21, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php", "line": 27, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php", "line": 62, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 104, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php", "line": 151, "call": "Illuminate\\Pipeline\\Pipeline::then(instance of Closure)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php", "line": 116, "call": "Illuminate\\Foundation\\Http\\Kernel::sendRequestThroughRouter(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\public\\index.php", "line": 55, "call": "Illuminate\\Foundation\\Http\\Kernel::handle(instance of Illuminate\\Http\\Request)" }, { "file": "C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\server.php", "line": 21, "function": "require_once('C:\\Users\\Lenovo\\Desktop\\Bitbucket\\postmaster-api\\public\\index.php')" } ] } ] }
Please advice.
Hi,
Is there an easy way to use a different field other than username, in my case email, for login? Right now it seems to be hardcoded for username.
Hi,
Thanks for your response with the other PHPUnit Testing issue I raised. I worked something out that is doing the trick. I will try not to ask anymore questions after this... I hope.
I have tried testing the authentication process with PHPUnit. I have managed to test all mutations apart from the logout.
$this->mutation('logout', ['status', 'message']); logout = the mutation, [status and message] = the LogoutResponse payload
When I run that, I get the below error message:
“message” => “Syntax Error: Expected Name, found Int”
It would seem that it is asking for a second parameter (Which I am guessing is the Authorization Bearer info), but in the schema, there are no parameters, just the payload:
Schema: logout: LogoutResponse!
Would appreciate a stir in the right direct.
I want to Login with Both Email and Phone Number when change in config
'username' => 'email'
I can only access by Email and Error when I try access by Phone Number as following
"debugMessage": "No query results for model [App\User].",
"message": "Internal server error",
"extensions": {
"category": "internal"
And change the
username' => 'phone_num'
I can only access by Phone Number and Error when I try access by Email same error as above.
So any idea
I try to add the
username' => ['phone_num','email']
"errors": [
{
"debugMessage": "SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'where clause' (SQL: select * fromusers
where (0
= email and1
= phone_num) limit 1)",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
Create a mutation to update a logged in user's password.
i see this error. When use lighthouse ^3.5
{
"errors": [
{
"message": "Schema is not configured for mutations.",
"extensions": {
"category": "graphql"
},
"locations": [
{
"line": 1,
"column": 1
}
]
}
]
}
I still don't know what's causing it but my application is sending email verification twice. I tried removing MustVerifyEmail and MustVerifyEmailGraphQL from AppUser model but it still continues doing so. This is not just a case of simple duplication of email. The verification is sent twice with different tokens which means that the notification (sendEmailVerificationNotification) is being called twice.
Upon inspection, the package calls the following in the Register resolver:
if ($model instanceof MustVerifyEmail) {
// called by package
$model->sendEmailVerificationNotification();
event(new Registered($model));
return [
'tokens' => [],
'status' => 'MUST_VERIFY_EMAIL',
];
}
Is this a bug?
I have the following error when with the login mutation:
mutation { login(input: { username: "[email protected]", password: "123123123" }) { access_token user { email name created_at updated_at } } }
The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.
I already setted my password grant client in the .env file.
Hi,
Scheme describes that refreshToken mutation should return AuthPayload type which respectively should contain non-nullable User.
But RefreshToken resolver returns just credentials.
Hi,
i have add this function in App/User.php
public function findForPassport($username)
{
return $this->where('username', $username)->first();
}
Confirm have the user data.
but there have error return:
"debugMessage": "No query results for model [App\User]."
in joselfonseca/lighthouse-graphql-passport-auth/src/GraphQL/Mutations/Login.php:
public function resolve($rootValue, array $args, GraphQLContext $context = null, ResolveInfo $resolveInfo)
{
$credentials = $this->buildCredentials($args);
$response = $this->makeRequest($credentials);
$user = app(config('auth.providers.users.model'))->where('email', $args['data']['username'])->firstOrFail(); <-after i delete this line
** $response['user'] = $user;** <-after i delete this line
return $response;
}
It will work fine. But this not seems to be a good way.
Any suggestion?
Hi,
Fitst of all: I love the package, great work!
I have a question regarding storage of the tokens in a frontend setting. It is bad practice to store them in localStorage for security reasons. A safer way is to store the refresh token in an httpOnly cookie (see http://esbenp.github.io/2017/03/19/modern-rest-api-laravel-part-4/ for reference). Currently the package does not take use of this
Are you planning to support this mechanism or is it easy enough to extend the functionality of the current package to start supporting this? For the latter: what would be the best way to do this?
Context:
I’m building a headless frontend app that will make use of a GraphQL endpoint to authenticate users (built with laravel). I’m concerned with the vulnerability of storing tokens in localStorage so I’m exploring alternative solutions.
Thanks!
Hi there, I read through your blog post regarding setup, and the instructions in this repo but when I attempt to login as per the blog post, I get the following error:
The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.
{
"message": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.",
"extensions": {
"guards": [],
"category": "authentication"
},
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"login"
]
}
For reference, I am using Homestead for development currently so not sure if this is an issue?
This is where the error trace stops:
> /joselfonseca/lighthouse-graphql-passport-auth/src/GraphQL/Mutations/Login.php
> BaseAuthResolver::makeRequest(array(5))
"trace": [
{
"file": "/home/vagrant/App/vendor/joselfonseca/lighthouse-graphql-passport-auth/src/GraphQL/Mutations/Login.php",
"line": 23,
"call": "Joselfonseca\\LighthouseGraphQLPassport\\GraphQL\\Mutations\\BaseAuthResolver::makeRequest(array(5))"
}
]
Any obvious errors that I am making?
Hola, te dejo el error al intentar ejecutar composer require joselfonseca/lighthouse-graphql-passport-auth
en un proyecto con laravel 6:
Using version ^2.0 for joselfonseca/lighthouse-graphql-passport-auth
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for laravel/passport (locked at v8.0.0, required as ^8.0) -> satisfiable by laravel/passport[v8.0.0].
- joselfonseca/lighthouse-graphql-passport-auth 2.0.0 requires laravel/passport ^7.0 -> satisfiable by laravel/passport[7.0.x-dev].
- joselfonseca/lighthouse-graphql-passport-auth 2.0.1 requires laravel/passport ^7.0 -> satisfiable by laravel/passport[7.0.x-dev].
- joselfonseca/lighthouse-graphql-passport-auth 2.0.2 requires laravel/passport ^7.0 -> satisfiable by laravel/passport[7.0.x-dev].
- joselfonseca/lighthouse-graphql-passport-auth 2.0.x-dev requires laravel/passport ^7.0 -> satisfiable by laravel/passport[7.0.x-dev].
- Conclusion: don't install laravel/passport 7.0.x-dev
- Installation request for joselfonseca/lighthouse-graphql-passport-auth ^2.0 -> satisfiable by joselfonseca/lighthouse-graphql-passport-auth[2.0.0, 2.0.1, 2.0.2, 2.0.x-dev].
Installation failed, reverting ./composer.json to its original content.
Imagen del error:
https://i.imgur.com/tRhDmfj.png
Te agradesco tu tiempo.
Mi config:
/*
|--------------------------------------------------------------------------
| Username Column
|--------------------------------------------------------------------------
|
| What column should be use for the username in the users table to find
| the user.
|
*/
'username' => 'username'
Query:
mutation login {
login(input: {
username: "admin",
password: "secret"
}) {
access_token
refresh_token
expires_in
token_type
user {
id
email
name
created_at
updated_at
}
}
}
Log output:
[2019-10-28 15:40:55] local.INFO: "select * from `oauth_clients` where `id` = ? limit 1"
[2019-10-28 15:40:55] local.INFO: ["2"]
[2019-10-28 15:40:55] local.INFO: 38.16
[2019-10-28 15:40:55] local.INFO: "select * from `users` where `email` = ? limit 1"
[2019-10-28 15:40:55] local.INFO: ["admin"]
[2019-10-28 15:40:55] local.INFO: 0.71
[2019-10-28 15:40:55] local.ERROR: The user credentials were incorrect. {"exception":"[object] ...
Como puedes ver, está buscando por el campo email en lugar de por username en la SQL.
Un saludo y muchísimas gracias por este estupendo plugin.
mutation {
login(input: {
username: "[email protected]",
password: "1234qwer"
}) {
access_token
refresh_token
expires_in
token_type
user {
id
email
name
created_at
updated_at
}
}
}
{
"errors": [
{
"message": "Client authentication failed",
"extensions": {
"guards": [],
"category": "authentication"
},
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"login"
],
So I've got everything up and running according to the tutorial, but I can't get the login resolver to return the user (Cannot return null for non-nullable field AuthPayload.company). My project is set up to use the company table instead of a users table.
I've also added a 'me' query me: Company @auth(guard: "api")
which works just fine! My experience with Laravel is somewhat limited, so I hope someone here can point me in the right direction.
Hi Jose,
I first want to thank you SO much for creating this package - its a great start to authentication via Lighthouse / GraphQL. The issue I am running into is password resets. It seems if I dont define a route like the following:
Route::post('password/reset', 'Joselfonseca\LighthouseGraphQLPassport\GraphQL\Mutations\ForgotPassword@resolve')->name('password.reset');
I get a response:
{
"errors": [
{
"debugMessage": "Route [password.reset] not defined.",
"message": "Internal server error",
...
Is there something in my config/auth.php
under passwords that I need to update to ensure I dont have to define a route / controller for this?
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
],
],
{
"errors": [
{
"extensions": {
"guards": []
},
"message": "Cache store [none] is not defined.",
"category": "authentication",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"login"
],
"trace": [
{
"file": "E:\Laravel\prototype\app\Http\GraphQL\Mutations\AccountMutator.php",
"line": 15,
"call": "App\Http\GraphQL\Mutations\BaseAuthResolver::makeRequest(array(5))"
},
{
"file": "E:\Laravel\prototype\vendor\nuwave\lighthouse\src\Support\helpers.php",
"line": 151,
"call": "App\Http\GraphQL\Mutations\AccountMutator::login(null, array(2), instance of Nuwave\Lighthouse\Schema\Context, instance of GraphQL\Type\Definition\ResolveInfo)"
},
{
"file": "E:\Laravel\prototype\vendor\nuwave\lighthouse\src\Schema\Directives\Fields\FieldDirective.php",
"line": 63,
"function": "{closure}(null, array(2), instance of Nuwave\Lighthouse\Schema\Context, instance of GraphQL\Type\Definition\ResolveInfo)"
},
{
"call": "Nuwave\Lighthouse\Schema\Directives\Fields\FieldDirective::Nuwave\Lighthouse\Schema\Directives\Fields\{closure}(null, array(1), instance of Nuwave\Lighthouse\Schema\Context, instance of GraphQL\Type\Definition\ResolveInfo)"
},
{
"file": "E:\Laravel\prototype\vendor\nuwave\lighthouse\src\Schema\Factories\FieldFactory.php",
"line": 108,
"function": "call_user_func_array(instance of Closure, array(4))"
},
{
"file": "E:\Laravel\prototype\vendor\nuwave\lighthouse\src\Schema\Factories\FieldFactory.php",
"line": 174,
"call": "Nuwave\Lighthouse\Schema\Factories\FieldFactory::Nuwave\Lighthouse\Schema\Factories\{closure}(null, array(1), instance of Nuwave\Lighthouse\Schema\Context, instance of GraphQL\Type\Definition\ResolveInfo)"
},
{
"file": "E:\Laravel\prototype\vendor\webonyx\graphql-php\src\Executor\Executor.php",
"line": 781,
"call": "Nuwave\Lighthouse\Schema\Factories\FieldFactory::Nuwave\Lighthouse\Schema\Factories\{closure}(null, array(1), instance of Nuwave\Lighthouse\Schema\Context, instance of GraphQL\Type\Definition\ResolveInfo)"
},
{
"file": "E:\Laravel\prototype\vendor\webonyx\graphql-php\src\Executor\Executor.php",
"line": 744,
"call": "GraphQL\Executor\Executor::resolveOrError(instance of GraphQL\Type\Definition\FieldDefinition, instance of GraphQL\Language\AST\FieldNode, instance of Closure, null, instance of Nuwave\Lighthouse\Schema\Context, instance of GraphQL\Type\Definition\ResolveInfo)"
},
{
"file": "E:\Laravel\prototype\vendor\webonyx\graphql-php\src\Executor\Executor.php",
"line": 429,
"call": "GraphQL\Executor\Executor::resolveField(GraphQLType: Mutation, null, instance of ArrayObject(1), array(1))"
},
{
"file": "E:\Laravel\prototype\vendor\webonyx\graphql-php\src\Executor\Executor.php",
"line": 446,
"call": "GraphQL\Executor\Executor::GraphQL\Executor\{closure}(array(0), 'login', array(0), GraphQLType: Mutation, null, instance of ArrayObject(1))"
},
{
"file": "E:\Laravel\prototype\vendor\webonyx\graphql-php\src\Executor\Promise\Adapter\SyncPromise.php",
"line": 135,
"call": "GraphQL\Executor\Executor::GraphQL\Executor\{closure}(array(0))"
},
{
"file": "E:\Laravel\prototype\vendor\webonyx\graphql-php\src\Executor\Promise\Adapter\SyncPromise.php",
"line": 35,
"call": "GraphQL\Executor\Promise\Adapter\SyncPromise::GraphQL\Executor\Promise\Adapter\{closure}()"
},
{
"file": "E:\Laravel\prototype\vendor\webonyx\graphql-php\src\Executor\Promise\Adapter\SyncPromiseAdapter.php",
"line": 140,
"call": "GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue()"
},
{
"file": "E:\Laravel\prototype\vendor\webonyx\graphql-php\src\GraphQL.php",
"line": 88,
"call": "GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter::wait(instance of GraphQL\Executor\Promise\Promise)"
},
{
"file": "E:\Laravel\prototype\vendor\nuwave\lighthouse\src\GraphQL.php",
"line": 113,
"call": "GraphQL\GraphQL::executeQuery(instance of GraphQL\Type\Schema, 'mutation {\n login(data: {username: "zz", password: "zz"}) {\n access_token\n }\n}', null, instance of Nuwave\Lighthouse\Schema\Context, array(0), null, null, array(29))"
},
{
"file": "E:\Laravel\prototype\vendor\nuwave\lighthouse\src\Support\Http\Controllers\GraphQLController.php",
"line": 83,
"call": "Nuwave\Lighthouse\GraphQL::executeQuery('mutation {\n login(data: {username: "zz", password: "zz"}) {\n access_token\n }\n}', instance of Nuwave\Lighthouse\Schema\Context, array(0))"
},
{
"file": "E:\Laravel\prototype\vendor\nuwave\lighthouse\src\Support\Http\Controllers\GraphQLController.php",
"line": 62,
"call": "Nuwave\Lighthouse\Support\Http\Controllers\GraphQLController::execute(instance of Illuminate\Http\Request)"
},
{
"call": "Nuwave\Lighthouse\Support\Http\Controllers\GraphQLController::query(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Controller.php",
"line": 54,
"function": "call_user_func_array(array(2), array(1))"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php",
"line": 45,
"call": "Illuminate\Routing\Controller::callAction('query', array(1))"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Route.php",
"line": 219,
"call": "Illuminate\Routing\ControllerDispatcher::dispatch(instance of Illuminate\Routing\Route, instance of Nuwave\Lighthouse\Support\Http\Controllers\GraphQLController, 'query')"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Route.php",
"line": 176,
"call": "Illuminate\Routing\Route::runController()"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
"line": 682,
"call": "Illuminate\Routing\Route::run()"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
"line": 30,
"call": "Illuminate\Routing\Router::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 104,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
"line": 684,
"call": "Illuminate\Pipeline\Pipeline::then(instance of Closure)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
"line": 659,
"call": "Illuminate\Routing\Router::runRouteWithinStack(instance of Illuminate\Routing\Route, instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
"line": 625,
"call": "Illuminate\Routing\Router::runRoute(instance of Illuminate\Http\Request, instance of Illuminate\Routing\Route)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
"line": 614,
"call": "Illuminate\Routing\Router::dispatchToRoute(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
"line": 176,
"call": "Illuminate\Routing\Router::dispatch(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
"line": 30,
"call": "Illuminate\Foundation\Http\Kernel::Illuminate\Foundation\Http\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\fideloper\proxy\src\TrustProxies.php",
"line": 57,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 151,
"call": "Fideloper\Proxy\TrustProxies::handle(instance of Illuminate\Http\Request, instance of Closure)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
"line": 53,
"call": "Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php",
"line": 31,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 151,
"call": "Illuminate\Foundation\Http\Middleware\TransformsRequest::handle(instance of Illuminate\Http\Request, instance of Closure)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
"line": 53,
"call": "Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php",
"line": 31,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 151,
"call": "Illuminate\Foundation\Http\Middleware\TransformsRequest::handle(instance of Illuminate\Http\Request, instance of Closure)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
"line": 53,
"call": "Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php",
"line": 27,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 151,
"call": "Illuminate\Foundation\Http\Middleware\ValidatePostSize::handle(instance of Illuminate\Http\Request, instance of Closure)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
"line": 53,
"call": "Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php",
"line": 62,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 151,
"call": "Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::handle(instance of Illuminate\Http\Request, instance of Closure)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php",
"line": 53,
"call": "Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 104,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
"line": 151,
"call": "Illuminate\Pipeline\Pipeline::then(instance of Closure)"
},
{
"file": "E:\Laravel\prototype\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
"line": 116,
"call": "Illuminate\Foundation\Http\Kernel::sendRequestThroughRouter(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\public\index.php",
"line": 55,
"call": "Illuminate\Foundation\Http\Kernel::handle(instance of Illuminate\Http\Request)"
},
{
"file": "E:\Laravel\prototype\server.php",
"line": 21,
"function": "require_once('E:\Laravel\prototype\public\index.php')"
}
]
}
],
"data": {
"login": null
}
}
When I run lighthouse-graphql-passport-auth/Login mutation I got this error.
Is there anyone resolved this?
Many thanks.
Hello @joselfonseca !
I have suggestion add support Laravel Socialite use with Laravel Passport.
Or maybe you can help how to modify your Mutation login
for set up grant_type
= social
, provider
= for example (facebook
) & access_token
from another OAuth application, for example Facebook.
Hello,
I have just installed laravel lighthouse and went to use this module and composer complained about requirements.
It would be great if you could update.
Thanks
Is the a way to disable the default introspection of the entire API within the config file?
That is to say that since lighthouse has some config to make this change and some security rules, how do I integrate this with the config file that this library creates after publishing?
Hello,
Sorry to be asking here but I hope you can help.
I was just wondering how you would recommend refreshing an access_token before it expires.
I'm guessing that the suggested method here is to store both the access_token and the refresh_token on the client side. When the access_token expires you can use the refresh_token to get a new access_token.
However I have read that storing the refresh_token in the browser is a bad idea as a hacker could use it to continually refresh a token indefinitely.
Is the above what you would recommend with this library or do you recommend something else?
I did notice this which prevents sending the actual tokens https://laravel.com/docs/5.7/passport#consuming-your-api-with-javascript
but it doesn't quite fit with graphql and doesn't resolve how to renew expired tokens.
Context: #77
Hello,
When I've got not passport keys yet in my project and the LighthouseGraphQLPassportServiceProvider
is being booted I got an error:
Key path "storage/oauth-private.key" does not exist or is not readable
When i try to run the php artisan passport:keys
command to generate these keys i still got the same error because it is already trying to do something with these keys.
Line that gives the error: LighthouseGraphQLPassportServiceProvider.php:28
Is there a way to fix this?
using the @auth is not working to return the authenticated user
type Query {
me: User @auth
...
}
{
"Authorization": "Bearer <token returned from login here>"
}
I have added (Laravel Password Grant Client)
PASSPORT_CLIENT_ID=
PASSPORT_CLIENT_SECRET=
in my .env file, but I keep on getting the error.
Thanks in advance.
Hi Jose, I want to be able to authenticate with the Contact
model instead of User
where I can make this change and what should I take into account when making that change?
Add @SPREAD directive in mutations with inputs, so $args will contain only the data that matters
auth.graphql
login(data: LoginInput @spread): AuthPayload!
Is it possible to use custom guards? My multi-auth has two other custom users not based on Laravels roles but just custom guards. How can you authenticate this kind of users in this kind of configuration?
I was wondering how I would test this package with PHPUnit.
I have been stuck on it for a day now. The original message I was getting was:
"The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed."
Then I realised that it might have something to do with the .env file. I have updated it and added:
PASSPORT_CLIENT_ID=
PASSPORT_CLIENT_SECRET=
Now I am getting:
"The user credentials were incorrect."
I am guessing this is because of the refreshing of the database. I have tried adding the information manually:
DB::table('oauth_clients')->insert([
'name' => 'Laravel Password Grant Client',
'secret' => 'JFOB3ClZdXx5KYICRbNuCC2KlnZjIlX20jHHoWCX',
'redirect' => 'http://localhost',
'personal_access_client' => 0,
'password_client' => 1,
'revoked' => 0
]);
But that still not working, and I would rather not have to add that in every test.
Any help would be appreciated.
*** UPDATE ***
No worries. I have got it working.
Add default Mutation to register a user.
Is it possible to modify the BaseAuthResolver so that client_id and client_secret can be used out of the request and get not obtained by the config?
Thanks in advance.
This is to set the logged in user based on the request so the $context object is able to get user. This is because the middleware directive was deprecated and the Guard directive only checks for the user to be logged in using a guard. Without this middleware $context->user()
will always be null
After logging in via API it will be commonly necessary to obtain the user account data "name, email, thumbnail URL, etc" for UI display purposes. I suggest that the AuthPayload ought to include the User model associated with the token in the response. Right now I am querying the User separately after auth which is kinda silly.
Version 2.1.0 adds Socialite support and includes this migration here:
https://github.com/joselfonseca/lighthouse-graphql-passport-auth/blob/master/migrations/2019_11_19_000000_update_social_provider_users_table.php
It is bound via the service provider as an obligatory migration however this is really only necessary for anyone using the Socialite feature. It should not be included in the service provider as an automatic migration, and instead should be provided via an Artisan command, or controlled via config toggle, or something similar.
Further to this, I suggest that the Socialite database implementation should be completely separate from the "users" table. It should not be modifying databases included by other Laravel services (in this case, base Laravel itself). The principle of separation of concerns should be better adhered to by creating its own database for this with "user_id" column to maintain the relationship and the database name should be adjustable in the "config" file just in case there is a collision.
Currently, any error that occur when trying to login is only
The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.
I understand that we do not want to expose errors to users but I think that errors should be categorized like so:
Anyway, I'm already working on my own solution at the moment. Just wanted to bring this up for succeeding versions of this package.
Thanks for the good work!
The title says it all. It seems that my version of PHP or server does not support this alias. I am using heroku hosting and php version 7.2. Well, for now, I just copied the update password mutation in my App/GraphQL/Mutations directory and removed instances of the function.
Any ideas on how to properly address this as I don't want to tamper on the package. It makes it hard to update. Thanks!
Cuando se hace una solicitud y el token ha expirado se obtiene este error:
{ "errors": [ { "debugMessage": "Unauthenticated.", "message": "Internal server error", "extensions": { "category": "internal" }, "locations": [ { "line": 2, "column": 3 } ], "path": [ "users" ], "trace": [ ... }
Sin embargo, en un entorno de producción la depuración está desactivada (APP_DEBUG=false) y el debugMessage desaparece. ¿Cómo puedo saber desde mi ciente que es un error de autenticación?
Un saludo desde España.
I managed to got the login working using username instead of email when I tried the link you gave thanks to that :) . But when I am trying to register another user it says 'Credentials were incorrect' but it was added anyways on the database.
Any plans on adding email verification in the registration part? Thanks!
The mutation creates the new user but does not return anything, generates an error
mutation {
register(input: {
name: "test10003"
email: "[email protected]",
password: "password",
password_confirmation: "password"
}) {
access_token
refresh_token
expires_in
token_type
user {
id
email
name
created_at
updated_at
}
}
}
This is what the request returns:
"errors": [
{
"debugMessage": "Class 'Illuminate\\Auth\\Events\\Debugbar' not found",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"register"
],
"trace": [
{
"file": "/home/vagrant/code/vendor/joselfonseca/lighthouse-graphql-passport-auth/src/GraphQL/Mutations/Register.php",
"line": 33,
"call": "Illuminate\\Auth\\Events\\Registered::__construct()"
},
{
"file": "/home/vagrant/code/vendor/nuwave/lighthouse/src/Schema/Directives/FieldDirective.php",
"line": 68,
"call": "Joselfonseca\\LighthouseGraphQLPassport\\GraphQL\\Mutations\\Register::resolve()"
},
{
"file": "/home/vagrant/code/vendor/nuwave/lighthouse/src/Schema/Factories/FieldFactory.php",
"line": 174,
"call":
Change the registration code for this one and it works correctly.
I don't know if they are the special conditions of my development environment but the class does not return the user created.
lighthouse-graphql-passport-auth/src/GraphQL/Mutations/Register.php
......
$response = $this->makeRequest($credentials);
$user = $model->where(config('lighthouse-graphql-passport.username'), $args['email'])->firstOrFail();
$response['user'] = $user;
return $response;
"require": {
"php": "^7.2",
"fideloper/proxy": "^4.0",
"joselfonseca/lighthouse-graphql-passport-auth": "^2.0.3",
"laravel/framework": "^6.2",
"laravel/passport": "7.5.1",
"laravel/tinker": "^1.0",
"nuwave/lighthouse": "^4.7"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"facade/ignition": "^1.4",
"fzaninotto/faker": "^1.4",
"laravel/homestead": "^10.0",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^8.0"
},
I had trouble setting this up at first, till I realised my problem.
if in the config file the schema is left as null
, I think it is calling the default
schema located in the vendor directory.
This may be a flaw or how it should be but it really pestered me. My default entry point for Lighthouse is defined in lighthouse.php
config. and from there I would import other Schema
The issue I faced was that your "vendor" schema was being registered with graphql, causing a conflict with my User Model (which doesnt have a name field etc etc)
SOLUTION: When publishing the config, if the schema is set to null, please point it to lighthouse configs default schema, as this causes conflicts
Steps to Reproduce
Steps to reproduce
run composer require joselfonseca/lighthouse-graphql-passport-auth
php artisan vendor:publish --provider="Joselfonseca\LighthouseGraphQLPassport\Providers\LighthouseGraphQLPassportServiceProvider"
type User
from auth.graphqlphp artisan lighthouse:print-schema still shows original auth schema
Result - prints out generated Schema based on your "default" schema which is located inside vendor.
type User {
id: ID!
name: String!
email: String!
}
this was printed out in the schema, which is your default.
Expected Result - Fallback to my default schema defined in lighthouse.php
type User {
id: ID!
username: String!
email: String!
events: [Event!]!
profile: Profile
}
When I tried to login, getting error:
graphQL
mutation{
login(data:{
username: "[email protected]",
password: "123456"
}){
access_token
refresh_token
expires_in
token_type
}
}```
Error
{
"errors": [
{
"message": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.",
"extensions": {
"guards": [],
"category": "authentication"
},
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"login"
],
"trace": [
{
"file": "/var/www/html/other/test/myProject/vendor/joselfonseca/lighthouse-graphql-passport-auth/src/GraphQL/Mutations/Login.php",
"line": 21,
"call": "Joselfonseca\LighthouseGraphQLPassport\GraphQL\Mutations\BaseAuthResolver::makeRequest(array(5))"
},
{
"file": "/var/www/html/other/test/myProject/vendor/nuwave/lighthouse/src/Schema/Directives/FieldDirective.php",
"line": 48,
"call": "Joselfonseca\LighthouseGraphQLPassport\GraphQL\Mutations\Login::resolve(null, array(2), instance of Nuwave\Lighthouse\Schema\Context, instance of GraphQL\Type\Definition\ResolveInfo)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/nuwave/lighthouse/src/Schema/Factories/FieldFactory.php",
"line": 221,
"call": "Nuwave\Lighthouse\Schema\Directives\FieldDirective::Nuwave\Lighthouse\Schema\Directives\{closure}(null, array(1), instance of Nuwave\Lighthouse\Schema\Context, instance of GraphQL\Type\Definition\ResolveInfo)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
"line": 632,
"call": "Nuwave\Lighthouse\Schema\Factories\FieldFactory::Nuwave\Lighthouse\Schema\Factories\{closure}(null, array(1), instance of Nuwave\Lighthouse\Schema\Context, instance of GraphQL\Type\Definition\ResolveInfo)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
"line": 560,
"call": "GraphQL\Executor\ReferenceExecutor::resolveOrError(instance of GraphQL\Type\Definition\FieldDefinition, instance of GraphQL\Language\AST\FieldNode, instance of Closure, null, instance of Nuwave\Lighthouse\Schema\Context, instance of GraphQL\Type\Definition\ResolveInfo)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
"line": 478,
"call": "GraphQL\Executor\ReferenceExecutor::resolveField(GraphQLType: Mutation, null, instance of ArrayObject(1), array(1))"
},
{
"file": "/var/www/html/other/test/myProject/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
"line": 921,
"call": "GraphQL\Executor\ReferenceExecutor::GraphQL\Executor\{closure}(array(0), 'login')"
},
{
"call": "GraphQL\Executor\ReferenceExecutor::GraphQL\Executor\{closure}(array(0), 'login')"
},
{
"file": "/var/www/html/other/test/myProject/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
"line": 923,
"function": "array_reduce(array(1), instance of Closure, array(0))"
},
{
"file": "/var/www/html/other/test/myProject/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
"line": 494,
"call": "GraphQL\Executor\ReferenceExecutor::promiseReduce(array(1), instance of Closure, array(0))"
},
{
"file": "/var/www/html/other/test/myProject/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
"line": 256,
"call": "GraphQL\Executor\ReferenceExecutor::executeFieldsSerially(GraphQLType: Mutation, null, array(0), instance of ArrayObject(1))"
},
{
"file": "/var/www/html/other/test/myProject/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
"line": 208,
"call": "GraphQL\Executor\ReferenceExecutor::executeOperation(instance of GraphQL\Language\AST\OperationDefinitionNode, null)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/webonyx/graphql-php/src/Executor/Executor.php",
"line": 155,
"call": "GraphQL\Executor\ReferenceExecutor::doExecute()"
},
{
"file": "/var/www/html/other/test/myProject/vendor/webonyx/graphql-php/src/GraphQL.php",
"line": 165,
"call": "GraphQL\Executor\Executor::promiseToExecute(instance of GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter, instance of GraphQL\Type\Schema, instance of GraphQL\Language\AST\DocumentNode, null, instance of Nuwave\Lighthouse\Schema\Context, array(0), null, null)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/webonyx/graphql-php/src/GraphQL.php",
"line": 98,
"call": "GraphQL\GraphQL::promiseToExecute(instance of GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter, instance of GraphQL\Type\Schema, 'mutation {\n login(data: {username: "[email protected]", password: "123456"}) {\n access_token\n refresh_token\n expires_in\n token_type\n }\n}', null, instance of Nuwave\Lighthouse\Schema\Context, array(0), null, null, array(29))"
},
{
"file": "/var/www/html/other/test/myProject/vendor/nuwave/lighthouse/src/GraphQL.php",
"line": 191,
"call": "GraphQL\GraphQL::executeQuery(instance of GraphQL\Type\Schema, 'mutation {\n login(data: {username: "[email protected]", password: "123456"}) {\n access_token\n refresh_token\n expires_in\n token_type\n }\n}', null, instance of Nuwave\Lighthouse\Schema\Context, array(0), null, null, array(29))"
},
{
"file": "/var/www/html/other/test/myProject/vendor/nuwave/lighthouse/src/GraphQL.php",
"line": 130,
"call": "Nuwave\Lighthouse\GraphQL::executeQuery('mutation {\n login(data: {username: "[email protected]", password: "123456"}) {\n access_token\n refresh_token\n expires_in\n token_type\n }\n}', instance of Nuwave\Lighthouse\Schema\Context, array(0), null, null)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php",
"line": 79,
"call": "Nuwave\Lighthouse\GraphQL::executeRequest(instance of Nuwave\Lighthouse\Execution\LighthouseRequest)"
},
{
"call": "Nuwave\Lighthouse\Support\Http\Controllers\GraphQLController::query(instance of Nuwave\Lighthouse\Execution\LighthouseRequest)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
"line": 54,
"function": "call_user_func_array(array(2), array(1))"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
"line": 45,
"call": "Illuminate\Routing\Controller::callAction('query', array(1))"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
"line": 219,
"call": "Illuminate\Routing\ControllerDispatcher::dispatch(instance of Illuminate\Routing\Route, instance of Nuwave\Lighthouse\Support\Http\Controllers\GraphQLController, 'query')"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
"line": 176,
"call": "Illuminate\Routing\Route::runController()"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 680,
"call": "Illuminate\Routing\Route::run()"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 30,
"call": "Illuminate\Routing\Router::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/nuwave/lighthouse/src/Support/Http/Middleware/AcceptJson.php",
"line": 30,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"call": "Nuwave\Lighthouse\Support\Http\Middleware\AcceptJson::handle(instance of Illuminate\Http\Request, instance of Closure)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"call": "Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 104,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 682,
"call": "Illuminate\Pipeline\Pipeline::then(instance of Closure)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 657,
"call": "Illuminate\Routing\Router::runRouteWithinStack(instance of Illuminate\Routing\Route, instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 623,
"call": "Illuminate\Routing\Router::runRoute(instance of Illuminate\Http\Request, instance of Illuminate\Routing\Route)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 612,
"call": "Illuminate\Routing\Router::dispatchToRoute(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 176,
"call": "Illuminate\Routing\Router::dispatch(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 30,
"call": "Illuminate\Foundation\Http\Kernel::Illuminate\Foundation\Http\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/fideloper/proxy/src/TrustProxies.php",
"line": 57,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"call": "Fideloper\Proxy\TrustProxies::handle(instance of Illuminate\Http\Request, instance of Closure)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"call": "Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 21,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"call": "Illuminate\Foundation\Http\Middleware\TransformsRequest::handle(instance of Illuminate\Http\Request, instance of Closure)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"call": "Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 21,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"call": "Illuminate\Foundation\Http\Middleware\TransformsRequest::handle(instance of Illuminate\Http\Request, instance of Closure)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"call": "Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
"line": 27,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"call": "Illuminate\Foundation\Http\Middleware\ValidatePostSize::handle(instance of Illuminate\Http\Request, instance of Closure)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"call": "Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php",
"line": 62,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"call": "Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::handle(instance of Illuminate\Http\Request, instance of Closure)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"call": "Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 104,
"call": "Illuminate\Routing\Pipeline::Illuminate\Routing\{closure}(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 151,
"call": "Illuminate\Pipeline\Pipeline::then(instance of Closure)"
},
{
"file": "/var/www/html/other/test/myProject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 116,
"call": "Illuminate\Foundation\Http\Kernel::sendRequestThroughRouter(instance of Illuminate\Http\Request)"
},
{
"file": "/var/www/html/other/test/myProject/public/index.php",
"line": 55,
"call": "Illuminate\Foundation\Http\Kernel::handle(instance of Illuminate\Http\Request)"
}
]
}
]
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.