oauth-ts
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

@thiagozf/oauth-ts

Codecov CircleCI

OAuth 2.0 authentication library

How to use

/* MyOAuthApp.ts */
import { OpenIDProvider, OAuthApplication, resolveProvider } from 'oauth-ts';
 
const provider: OpenIDProvider = await resolveProvider(
  'https://my.oidc.provider.com'
);
 
export const oauthApp: OAuthApplication = new OAuthApplication({
  provider,
  clientId: 'my_client_id',
  redirectUri: 'http://localhost:3000/callback',
  silentRedirectUri: 'http://localhost:3000/silent-callback',
  scope: 'read write',
  flow: 'IMPLICIT'
});
 
/* index.ts */
import { oauthApp } from './MyOAuthApp';
 
if (!oauthApp.hasActiveSession()) {
  return oauthApp.login();
}
 
console.log(oauthApp.getUser());
 
/* callback.ts */
import { oauthApp } from './MyOAuthApp';
 
oauthApp.handleCallback();

Readme

Keywords

none

Package Sidebar

Install

npm i oauth-ts

Weekly Downloads

3

Version

0.0.4

License

MIT

Unpacked Size

231 kB

Total Files

277

Last publish

Collaborators

  • thiagozf