panva / openid-client

OAuth 2 / OpenID Connect Client API for JavaScript Runtimes
MIT License
1.83k stars 392 forks source link

Examples #210

Closed m15ch4 closed 4 years ago

m15ch4 commented 4 years ago

Hi guys!

Could you please provide some examples how to use openid-client (especially with Electron).

Thanks.

panva commented 4 years ago

especially with Electron

not gonna go ahead and write a full blown sample but inside electron you should be able to incorporate either of the CLI ready examples

Both dynamically register a client, that's what you'd usually replace with a static client configuration and you should use shell.openItem instead of open in electron.

hegelstad commented 4 years ago

I have a problem that is not a problem with your library per se, but I would like to know if you can create an example of how to snapshot the current issuer that would be created with Issuer.discover()? The reason I am asking is that I am trying to incorporate this library as a strategy in NestJS's Passport module, but it doesn't play very well with async calls, so I would just like to quickly instantiate issuer once with discover, and then perhaps through serialization, be able to statically recreate that Issuer based on the snapshot.

panva commented 4 years ago

@hegelstad docs to the rescue

issuer.metadata gives you the metadata that was discovered, you can then do new Issuer(metadata) with that object. Just mind you that you should not be re-using it forever. At some point a re-discovery might make sense.