open-index/open-npm huggingface dataset:
npm package: @iterout/0auth-module
Description: 0auth module for backend application
Author: Mattia Bonardi
Latest version: 1.0.4

# 0auth-module

0auth module for backend application

## Installation

```bash
npm install @iterout/0auth-module
```

## Google

### Configuration

Create `GOOGLE_CLIENT_ID` from [google cloud console](https://console.cloud.google.com/).

```bash
import { oAuthConfiguration } from "@iterout/0auth-module";

oAuthConfiguration.setGoogleClientId([GOOGLE_CLIENT_ID]);
```

### SignIn

Google signin with `@iterout/auth-module` integration.
User already registered: login.
New user: registration and login.

```bash
import { googleSignIn } from "@iterout/0auth-module";

const tokens: TokenData = await googleSignIn(
  googleToken: string,
  userType: string,
  userRoles: string[]
);
```

#### Client side integration

Vue.js

```vue
<template>
  <div>
    <!-- google sign in -->
    <div
      id="g_id_onload"
      data-client_id="[GOOGLE_CLIENT_ID]"
      data-login_uri="[BACKEND_ENDPOINT]"
      data-auto_prompt="false"
    ></div>
    <div
      class="g_id_signin"
      data-type="standard"
      data-size="large"
      data-theme="outline"
      data-text="sign_in_with"
      data-shape="rectangular"
      data-logo_alignment="left"
    ></div>
  </div>
</template>

<script setup>
onMounted(() => {
  const googleSignInScript = document.createElement("script");
  googleSignInScript.setAttribute(
    "src",
    "https://accounts.google.com/gsi/client"
  );
  document.head.appendChild(googleSignInScript);
});
</script>
```