I'm trying to integrate an oauth2 server with an API and got terribly stuck. In the example, there are 3 different Strategies used (local, basic, bearer); Is there an explanation for that? How do I create client keys and secrets? Is there a working example for a simple login for users?
Yes, you are in for a headache :). It's not an easy to implement strategy but here is the full working example with token server and so on:
https://github.com/jaredhanson/oauth2orize
It took me several weeks to wrap my head around it and what helped a lot is to understand the Oauth2 specs themselves. There are many moving parts, in short as follows:
As you can see the complications appear that there is a need to a Token Server which you need to provide to ensure that Webmail is registered with the token server as "known provider" so then user grants Webmail a permission to access FB on their behalf.
On your Webmail side you will not use any of the local/basic/bearer strategies. You will use passport-oauth2 strategy. Bearer is a valid API strategy similar to presenting an API key. If you don't need user permission to grant access to an API, I highly recommend you use passport-http-bearer strategy and you have no headaches.
I hope it helps.
For future reference, I patched everything together in a small, understandable example. oauth2api
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With