Category : api

The api I built wqith apssport and laravel 8 does not logout by default. I found a script, but it does not remove the entries in the oauth-access-tokens table I afdded a function to the AuthController: public function logout(Request $request){ $accessToken = auth()->user()->token(); $token= $request->user()->tokens->find($accessToken); $token->revoke(); return response([‘message’=> ‘Je bent uitgelogd’], 200); } And added ..

Read more

Hello i adding new payment method but ipn i get Invalid Request this payment not needed adding i try all time but can’t i want help public static function process($deposit) { $kashierAcc = json_decode($deposit->gateway_currency()->gateway_parameter); // API request and response for creating an order $mid = $kashierAcc->merchant_id; $secret = $kashierAcc->secret_key; $val[‘amount’] = round($deposit->final_amo * 100); $val[‘currency’] ..

Read more

i am a bit confused as i have tried what i understand about fetching an item in an array in an object . let me break down in my client endpoint $client=Client::where(‘id’,$client)->firstOrFail(); $arr = json_decode($client->attributes); return response()->json($arr); when i return like this return response()->json($client->attributes); i get { "full_details_acknowledgement": "10", "offer_letter_acknowledgement": "10", "offer_letter": "10", "offer_letter_variables": [ ..

Read more

I try to combine JWT custom UserProvider. Users are store in external DB, accessed with API. config/auth.php ‘defaults’ => [ ‘guard’ => ‘api’, ‘passwords’ => ‘users’, ], ‘guards’ => [ ‘web’ => [ ‘driver’ => ‘jwt’, ‘provider’ => ‘shopAPI’, ], ‘api’ => [ ‘driver’ => ‘jwt’, ‘provider’ => ‘shopAPI’, ], ], ‘providers’ => [ ‘shopAPI’ ..

Read more

Im still new in back-end development and laravel. I’m using Laravel 8. I want to fetch an api and access only the countries data, I can’t figure out how to access it individually using foreach or any other method. here is my fetch function: function countries() { $data = Http::get(‘https://api.first.org/data/v1/countries’); //return json_decode($data); return view(‘v_Country’, [‘data’ ..

Read more

Im still new in back-end development and laravel. I’m using Laravel 8. I want to fetch an api and access only the countries data, I can’t figure out how to access it individually using foreach or any other method. here is my fetch function: function countries() { $data = Http::get(‘https://api.first.org/data/v1/countries’); //return json_decode($data); return view(‘v_Country’, [‘data’ ..

Read more

I’m using laravel 8 (Laravel Framework 8.64.0) to create an API. But when make a call to an endpoint, which i define with Route::apiResource it doesn’t return the result from a query, returns nothing. routesapi.php <?php use IlluminateHttpRequest; use IlluminateSupportFacadesRoute; use AppHttpControllersApiTodoController; /* |————————————————————————– | API Routes |————————————————————————– | | Here is where you can ..

Read more

I am facing strange behavior with laravel api responses, sometime response be correct with 1 json object with data and other times returns an extra json object with the inputs e.g. for api login endpoint api/login public function login(Request $request) { $loginData = $request->validate([ ’email’ => ’email|required’, ‘password’ => ‘required’ ]); $user = User::where(’email’, $request->email)->first(); ..

Read more

I’m trying to authenticate my api route with sanctum while using vue.js but I’m getting a headers error bootstarp.js axios.interceptors.request.use(function (config) { config.headers.common = { ‘Authorization’: `Bearer ${localStorage.getItem(‘token’)}`, ‘Content-Type’: ‘application/json’, ‘Accept’: ‘application/json’ } return config }) Getting this error DOMException: Failed to execute ‘setRequestHeader’ on ‘XMLHttpRequest’: ‘Bearer 100|paUaKhln1hiQUGWUyRshAC5fL8qS9qMhsR5n6CHd’ is not a valid HTTP header field ..

Read more

I have created an authentication with JWT in custom table. Authentication works fine, i am able to login and token is generated with success. The problem is not being able to get the information like ‘id’ etc FROM the generated TOKEN of the custom table. $token = $request->header(‘Authorization’); $user = JWTAuth::toUser($token); return $user; Returned information ..

Read more

I want delete a post with authorization but failed with error "message": false, "errors": "This action is unauthorized." destroy controller public function destroy($id, Post $post) { try { $this->authorize(‘delete’, $post); $posts = Post::find($id); $posts->delete(); return response()->json([ ‘success’ => true, ‘message’ => ‘Success’ ]); } catch (Exception $e) { return response()->json([ ‘message’ => false, ‘errors’ => ..

Read more

I have 2 tables related to creating credit notes which allows selecting multiple invoices. I was able to store the data into a database using postman(api controller), but having problems in API integration with the frontend. Database Credit Note id credit_note_group_id invoice_id code remarks amount 7 4 5 CN0006 cn remarks 150.00 8 4 8 ..

Read more

Could anyone please explain how to use Microsoft Graph API’s calendar/getSchedule request for application permission type? I am using the the it in my app as a cronjob, means that i need to use ‘POST /users/{id|userPrincipalName}/calendar/getSchedule’ instead of ‘POST /me/calendar/getSchedule’ since the later requires a user to sign in. My question is which user I ..

Read more