@kejax You could inspect the user agent information within in the request:
request()->server('HTTP_USER_AGENT')
But there is no guarantee if someone is being malicious.. this information can easily be altered by the requesting client.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Is there a way to check if an 3rd party oauth app was used to interact with the endpoint? If so, how would I be getting the client information?
I've been searching this forum and google for an answer, nothing that answers my question so far.
Thanks for any help in advance!
@Kejax Gotcha.
If you’re authenticating using an OAuth bearer token, then the authenticated user instance will have a token method that you can use to get the Token model, and its client relation:
Route::middleware('auth:api')->group(function () {
// Routes protected with auth:api middleware
});
public function someControllerAction(Request $request)
{
// Get authenticated user
$user = $request->user();
// Get Token model user used to authorise request
$token = $user->token();
// Get the client associated with the token
$client = $token->client;
}
So from the Client model instance, you can access its attributes, including name, or just use the client_id from the token itself to save in your post model:
class PostController extends Controller
{
public function store(StorePostRequest $request)
{
$user = $request->user();
$post = $user->posts()->make($request->validated());
$post->client()->associate($user->token()->client)->save();
// Return response...
}
}
This is assuming your Post model has a client relation that points to a Laravel\Passport\Client model instance:
@foreach($posts as $post)
<h1>{{ $post->headline }}</h1>
@if($post->client)
<p>This post was uploaded via {{ $post->client->name }}</p>
@endif
@endforeach
Please or to participate in this conversation.