Category : unauthorized

I have flutter app use login with facebook and gmail ,I want after register to return data conatin token. I have no problem with request which register in database successfully. but I get error : Unauthorized message after the request done and registered successfully : $user = User::create( [ ‘social_id’=>$request->id, ‘username’=>$request->username, ’email’=>$request->email, ‘pics’=>$request->pics, ‘role’=>’user’ ]); ..

Read more

hello I have a problem in react and laravel sanctum, it’s running fine when I test on postman, but it showing an error 401 Unauthorized when I implementing it in react i put this on my .env laravel file SANCTUM_STATEFUL_DOMAINS=localhost:3000 SESSION_DRIVER=cookie SESSION_DOMAIN=localhost this my stateful domain ‘stateful’ => explode(‘,’, env( ‘SANCTUM_STATEFUL_DOMAINS’, ‘localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1,’ . parse_url(env(‘APP_URL’), PHP_URL_HOST), ..

Read more

i am new to ReactJS in Laravel. When i send post request with axios, it gives me error of unauthorized. in api.php: Route::post("/newsfeed",[PostController::class,"store"])->middleware("auth:api"); Axios request i am sending: this.handleSubmit = (e) => { e.preventDefault(); const post = { title: this.state.title, content: this.state.content } axios.post("http://127.0.0.1:8000/api/newsfeed",post) .then((resp) => { console.log(resp); }) .catch((err) => { console.log(err); }) } ..

Read more

I watched this tutorial for api token authentication with laravel sanctum. When logging in, I retrieve a Bearer token which I add to the axios header. But when trying to fetch the user via /api/user, I get a 401. Notice that I don’t use CSRF tokens since I’m using Sanctum Api Token Authentication and not ..

Read more