# cordova-plugin-firebase-auth-google

> Adds support for Firebase authentication.

Latest version **1.3.1** (published 2019-08-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install cordova-plugin-firebase-auth-google
pnpm add cordova-plugin-firebase-auth-google
yarn add cordova-plugin-firebase-auth-google
bun add cordova-plugin-firebase-auth-google
```

## 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.3.1 |
| Published | 2019-08-06 |
| First published | 2018-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 32.5 KB |
| Known vulnerabilities | 0 (+4 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Carlos "blakgeek" Lawton |
| Maintainers | blakgeek |
| Keywords | ecosystem:cordova, cordova-android, cordova-ios, firebase, authentication, auth |

## Links

- npm: https://www.npmjs.com/package/cordova-plugin-firebase-auth-google
- Repository: https://github.com/blakgeek/cordova-plugin-firebase-auth-google
- Issues: https://github.com/blakgeek/cordova-plugin-firebase-auth-google/issues
- npm.io page: https://npm.io/package/cordova-plugin-firebase-auth-google

## Dependencies (5)

- [plist](https://npm.io/package/plist.md) ^1.2.0
- [xcode](https://npm.io/package/xcode.md) ^0.8.9
- [xml2js](https://npm.io/package/xml2js.md) ^0.4.17
- [shelljs](https://npm.io/package/shelljs.md) ^0.7.2
- [elementtree](https://npm.io/package/elementtree.md) ^0.1.6

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 1.3.1 (latest) — 2019-08-06
- 1.3.0 — 2019-08-01
- 1.1.6 — 2018-06-25
- 1.1.5 — 2018-06-05
- 1.1.4 — 2018-06-05
- 1.1.3 — 2018-06-05

## README

# cordova-plugin-firebase-auth-google
A super awesome plugin that let's you login into you app Firebase and a Google account.
 
## How do I install it?

If you're like me and using [Cordova CLI](http://cordova.apache.org/):
```
cordova plugin add cordova-plugin-firebase-auth-google
```

or

```
phonegap local plugin add cordova-plugin-app-name --variable APP_NAME="Look <Ma> I Got Spaces and Stuff!"
```

## How do I use it?
1. Download the google-services.json and/or GoogleService-Info.plist for you application from the Firebase console.
1. Copy the files from previous step to root of your project.  If you don't do this plugin's hook won't be able to copy 
them to the appropriate locations and bad things will happen at runtime.  So make you do this.
1. Now you're ready to write some code.

```javascript
const fbAuth = new FirebaseAuth({
    allowDomains: ['blakgeek.com'] // optionally restrict the domains that can used to log into the app.
})
````

## How do I sign in
```javascript
// on succesful sign in this event will be fired on the window (fancy name huh?)
window.addEventListener('signinsuccess', function (event) {

    console.log('Wassup?');
    // the detail property of the event will contain the information about the user 
    // ("token", "id", "name", "email", "id",  "photoUrl")
    console.dir(event.detail);
}, false);

// on an error during sign in this even will raised
window.addEventListener('signinfailure', function (event) {

    console.error('Oh snap');
    // the detail property will contain the error details 
    // (code, message and optionally the domain)
    // domain is included if the domain of user's email was not in the allowDomain list
    console.error(event.detail)
}, false);

// sign in by showing a UI
fbAuth.signIn();

// attempt to sign in without a UI (silently)
fbAuth.signIn(true); 
```

## How do I sign out?
```javascript
window.addEventListener('signoutsuccess', function (event) {

    console.log('Holla!')
}, false);
fbAuth.signOut();
```

## How do I get the user's token?
```javascript
fbAuth.getToken().then(token => {
    console.log(token);
}).catch(err => {
    console.error(err);
});
// or old school 
fbAuth.getToken(token => {
    console.log(token);
}, err => {
    console.error(err);
});
```

---
_Source: https://npm.io/package/cordova-plugin-firebase-auth-google · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
