This repository has been archived by the owner. It is now read-only.
Client-side Google authentication provider for sensenet ECM
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
src
test
.gitignore
.npmignore
.travis.yml
CONTRIBUTING.md
LICENSE
README.md
package-lock.json
package.json
tsconfig.json
tsconfig.test.json
tslint.json

README.md

sn-client-auth-google


This package is not under active development. You can find our latest packages in the sensenset/sn-client monorepo.


Gitter chat Build Status codecov License Commitizen friendly Greenkeeper badge

This package contains a client-side Google Oauth2 authentication provider for sensenet.

Installation

npm install @sensenet/authentication-google

Usage

Prerequisites

Setup

You can set up the Provider after creating your repository singleton with the addGoogleAuth method

import { Repository } from "@sensenet/client-core";
import { JwtService } from "@sensenet/authentication-jwt";
import { addGoogleAuth } from '@sensenet/authentication-google';

const repo = new Repository();
const jwt = new JwtService(repo);
const googleOauthProvider = addGoogleAuth(jwt, {clientId: ""});

Login

In your login component, you can use the following snippet. If you don't provide an id_token from an external component, the package will try to retrieve it using a popup window (in that case you have to enable popups and add a callback pointing to your window's origin)

// an example login method with an optional idToken:
async Login(idToken?: string){
 try {
     await googleOauthProvider.login(idToken);
     console.log('Logged in');
 } catch (error) {
    console.warn('Error during login', error);
 }
}