0.0.4 • Published 5 years ago

oauth-ts v0.0.4

Weekly downloads
3
License
MIT
Repository
-
Last release
5 years ago

@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();
0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago