PowerShell example for authenticating on behalf of a user.
Before you begin using this script, you'll need to create an app registration. I will not detail the full breakdown of creating an app registration as it's extensively covered by various sources. I will however confirm the sections of configuration needed to make this work.
Redirect for single page application:
In the highlighted section add:
http://localhost:5000
Apply Delegated API permissions to the application for the required operations you need:

Then generate a secret for the app registration.
Finally grant your user account access to the application registration & replace the details at the top of the script & run it!
If not signed in, you will be asked for your credentials. If successful you will be told to close the browser. In your powershell window you will be greeted with a Graph API call displaying the user signed in.
You can now make calls to the Graph API as your signed in user.