Implementing OAuth2 by thephpleague

I apologise in advance.

I’m completely new to the Slim framework, but I got a working simple API up and running. The only thing I need is to add OAuth2 to move on with my project. I need to generate a token based on clientId and clientSecret.

But I’m completely stuck on how to implement this. And a bit desperate! The examples from The Php League doesn’t seem to follow the same logic as my project does. Does anyone have a simple working example that has this implemented?

No need to apologize! The OAuth flow is already standardized. Can you please add more details about your project specific logic? What is the difference between the OAuth flow and your requirements?

The problem is probably that I don’t understand how to implement to examples. I have a index.php file in the public folder that initiates the $app adds middleware and routes and so on.

This example looks promising:

But I don’t understand how to integrate it with the rest of the application? This example defines it’s own $app and adds routes and functions. How can I make functionality that generates a token and authorizes the token available to be used on the other endpoints in my routes?