@bethasistemas/oauth-tsdeprecated

OAuth 2.0 authentication library

Usage no npm install needed!

<script type="module">
  import bethasistemasOauthTs from 'https://cdn.skypack.dev/@bethasistemas/oauth-ts';
</script>

README

@bethasistemas/oauth-ts

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