Category : jwt

i have a problem like this: I’m using Laravel to create a project I’m using Tymon/JWT for authentication too But i modified something for my purpose After that when i push it in Github, the auth-jwt folder contains nothing Because i modified something else in Vendor directory too, so i removed /vendor in .gitignore Everything ..

Read more

I want to generate a jwt token using sanctum without user login! $user = DB::table(‘social_facebook_accounts’) ->select(‘id’ ,’provider_user_id’,’provider’) ->get() ->sortByDesc(‘updated_at’) ->first(); if($user->provider_user_id == $userid){ $success[‘token’] = $user->createToken(‘facebook’)->accessToken; return response()->json([‘success’ => $success], $this->successStatus); }else{ return response()->json([‘error’=>’Unauthorised’], 401); } error I am getting => Call to undefined method stdClass::createToken() Sourc..

Read more

When I used to login the username and password via a web it is working whereas trying to authenticate via API with the same credentials it is not working. I have used the following code: $this->validate($request, [ ‘device_id’ => ‘required’, ‘device_type’ => ‘required|in:android,ios’, ‘device_token’ => ‘required’, ’email’ => ‘required|email’, ‘password’ => ‘required|min:6’, ]); Config::set(‘auth.providers.users.model’, ‘AppProvider’); ..

Read more

addProduct() { let uri = ‘http://localhost:8000/api/auth/product’; let jwttoken = localStorage.getItem(‘token’) this.axios.post(uri, this.product, {headers: { Authorization: ‘Bearer ‘ + jwttoken } }).then((response) => { console.log("Success: ", response.data) }).catch( (err) => { console.log("Error: ", err.response.data.errors) }); } This code is giving me the below Exception: "Array to string conversion" What is the problem? I am using Vue-Cli ..

Read more

im using PHP 7.3 (Xampp) composer version Composer version 2.0.8 2020-12-03 17:20:38(recently updade from version 1) Laravel 8 by using composer require tymon/jwt-auth command i cant install tymon/jwt-auth package inside in laravel 8 but I can install the same package inside empty php package using composer my issue why it is couldn’t install inside laravel ..

Read more

I am using Laravel Passport to Auth user in my Laravel API. I would like to know if it is possible to add custom data to the token generated by Passport: // /login endpoint Auth::attempt($credentials); $user = $request->user(); $token = $user->createToken(‘ACCESS_TOKEN’)->accessToken; return response()->json([‘token’ => $token]); // /me endpoint $user = $request()->user(); return response()->json([‘user_data’ => $user]); ..

Read more

I have problem on my jwt authentication. When I hit the api for the login of admin it shows error on my postman says that "message": "Argument 2 passed to TymonJWTAuthJWTGuard::__construct() must be an instance of IlluminateContractsAuthUserProvider, null given. I read some threads regarding on this, they said that there is problem on auth.php of ..

Read more

Laravel web auth was working well. I’m trying to use jwt-auth module. Here’s my code with jwt-auth module —authcontroller.php public function login(Request $request) { $validator = Validator::make($request->all(), [ ’email’ => ‘required|email’, ‘password’ => ‘required|string|min:6’, ]); if ($validator->fails()) { // return response()->json($validator->errors(), 200); session()->flash(‘error’, json_encode($validator->errors())); return back()->withInput(); } if (!$token = auth()->attempt($validator->validated())) { // return response()->json([‘error’ ..

Read more

I am using laravel/passport for api authentication Today My old access token isn’t working and When i try to generate new access token then i got Implicit conversion of keys from strings is deprecated. Please use InMemory or LocalFileReference classes. {"exception":"[object] (ErrorException(code: 0): Implicit conversion of keys from strings is deprecated. Please use InMemory or ..

Read more

I have module where I need to separately setup the controller of Admin Authentication and User Authentication. Right now I experience error on my postman it says that NotFoundHttpException. My Goal is to have separate link api. "exception": "SymfonyComponentHttpKernelExceptionNotFoundHttpException", Whole Image Error Postman: Here is the setup I made: Auth.php <?php return [ /* |————————————————————————– ..

Read more

TL;DR: JWT authenticates with credentials properly and then logs the users from both models (Admin and Employee) with the same token. I have three separate guards: admin, employee and trainer. Admin and Trainer login using eloquent driver and uses ‘admin’ and ‘trainer’ guard respectively. Employees login using ldap driver and uses ‘user’ guard. I’m using ..

Read more

Im new at Laravel, i made a login page for my backend application(its working fine) and then i did the JWT documentation to install and begin to use(https://jwt-auth.readthedocs.io/en/develop/). In my Controllers i used after: **public function __construct() { $this->middleware(‘auth:api’, [‘except’ => [‘login’]]); }** Now everytime i try to enter my same login i cant. How ..

Read more