If you are looking to generate an access token as an app, have a look at the following guide:
Get access without a user
https://learn.microsoft.com/en-us/graph/auth-v2-service?tabs=http
"To call Microsoft Graph, an app must obtain an access token from the Microsoft identity platform. This access token includes information about whether the app is authorized to access Microsoft Graph on behalf of a signed-in user or with its own identity. This article provides guidance on how an app can access Microsoft Graph with its own identity, also called app-only access."
If this is helpful please accept answer.