# @hlynurstef/bs-google-signin

> ReasonML bindings for @react-native-community/google-signin

Latest version **1.0.2** (published 2020-05-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hlynurstef/bs-google-signin
pnpm add @hlynurstef/bs-google-signin
yarn add @hlynurstef/bs-google-signin
bun add @hlynurstef/bs-google-signin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-05-02 |
| First published | 2020-05-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 108.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | hlynurstef |
| Maintainers | hlynurstef |
| Keywords | bs-google-signin, bucklescript, reasonml, reason |

## Links

- npm: https://www.npmjs.com/package/@hlynurstef/bs-google-signin
- Repository: https://github.com/hlynurstef/bs-google-signin
- Homepage: https://github.com/hlynurstef/bs-google-signin#readme
- Issues: https://github.com/hlynurstef/bs-google-signin/issues
- npm.io page: https://npm.io/package/@hlynurstef/bs-google-signin

## Recent versions

- 1.0.2 (latest) — 2020-05-02
- 1.0.1 — 2020-05-01
- 1.0.0 — 2020-05-01

## README

<p align="center">
  <img alt="reason-ml" src="assets/reason.png" width="300">
  <img alt="google-signin-button" src="assets/google-signin-button.png" width="300">
</p>

<h1 align="center">
  @hlynurstef/bs-google-signin
</h1>

<p align="center">
  <a href="https://reasonml.github.io/">ReasonML</a> bindings for <a href="https://github.com/react-native-community/google-signin">@react-native-community/google-signin</a>
</p>

---

<div align="center">

![npm](https://img.shields.io/npm/v/@hlynurstef/bs-google-signin)
![npm](https://img.shields.io/npm/dt/@hlynurstef/bs-google-signin)
![GitHub last commit](https://img.shields.io/github/last-commit/hlynurstef/bs-google-signin)
![GitHub](https://img.shields.io/github/license/hlynurstef/bs-google-signin)
![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen)

</div>

# Installation

Use yarn or npm

`yarn add @hlynurstef/bs-google-signin`

Then add `@hlynurstef/bs-google-signin` to `bs-dependencies` in your `bsconfig.json`:

```
{
  ...
  "bs-dependencies": ["@hlynurstef/bs-google-signin"]
}
```

# Example Usage

## Configure

```
GoogleSignin.configure(
  GoogleSignin.config(
    ~webClientId="your-id-here",
    (),
  ),
);
```

## Sign In

```
GoogleSignin.(
  hasPlayServices(playServicesConfig(~showPlayServicesUpdateDialog=true))
  |> Js.Promise.then_(_ => signIn())
  |> Js.Promise.then_((userInfo: UserInfo.t) => {
       Js.Console.log2("idToken:", userInfo->UserInfo.idToken);
       Js.Console.log2("serverAuthCode:", userInfo->UserInfo.serverAuthCode);

       let user = userInfo->UserInfo.user;
       Js.Console.log2("user.id:", user->User.id);
       Js.Console.log2("user.name:", user->User.name);
       Js.Console.log2("user.email:", user->User.email);
       Js.Console.log2("user.photo:", user->User.photo);
       Js.Console.log2("user.givenName:", user->User.givenName);
       Js.Console.log2("user.familyName:", user->User.familyName);
       Js.Promise.resolve();
     })
  |> Js.Promise.catch(exn =>
       switch (exnToGoogleSigninError(exn)) {
       | SignInCancelled(message)
       | PlayServicesNotAvailable(message)
       | InProgress(message)
       | SignInRequired(message)
       | GoogleSignin.Error(message) =>
         Js.Promise.resolve(Js.Console.log2("GoogleSignin failed:", message))
       }
     )
);
```

## Google Signin Button

```
<GoogleSignin.GoogleSignInButton
  size=`Wide
  color=`Light
  disabled=false
  onPress=(_ => ())
/>
```

# Contributing

1. Fork this repo and clone it onto your machine.
2. Run `yarn install` in the root directory.
3. Start the compiler with `yarn watch` in the root directory.
4. Create a PR to this repo with your changes.

---
_Source: https://npm.io/package/@hlynurstef/bs-google-signin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
