npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hristo2612/capacitor-google-auth

v0.0.1

Published

Capacitor Plugin for authenticating Google Users

Downloads

2

Readme

CapacitorGoogleAuth

Capacitor plugin for Google Auth. ( This is a fixed version of @codetrix-studio/capacitor-google-auth for Capacitor 3+

Contributions

PRs are welcome and much appreciated that keeps this plugin up to date with Capacitor and official Google Auth platform library feature parity.

Try to follow good code practices. You can even help keeping the included demo updated.

PRs for features that are not aligned with the official Google Auth library are discouraged.

(We are beginner-friendly here)

Install

1. Install package

npm i @hristo2612/capacitor-google-auth

2. Update capacitor deps

npx cap update

Usage

Integration For the Browser

Add clientId meta tag to head in index.html.

<meta name="google-signin-client_id" content="{your client id here}" />

Register plugin and manually initialize

import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';

// use hook after platform dom ready
GoogleAuth.init();

Use it

GoogleAuth.signIn();

AngularFire & Firebase

init hook & sign in function

import { GoogleAuth } from '@hristo2612/capacitor-google-auth';
import { AngularFireAuth } from '@angular/fire/auth';
import firebase from 'firebase/app';
import 'firebase/auth';

// app.component.ts
constructor(private afAuth: AngularFireAuth) {
  this.initializeApp();
}

initializeApp() {
  this.platform.ready().then(() => {
    GoogleAuth.init();
  });
}

async googleSignIn() {
  let googleUser = await GoogleAuth.signIn();
  const credential = firebase.auth.GoogleAuthProvider.credential(googleUser.authentication.idToken);
  return this.afAuth.signInWithCredential(credential);
}

iOS Integration

Make sure you have GoogleService-Info.plist with CLIENT_ID

Add REVERSED_CLIENT_ID as url scheme to Info.plist

Android Integration

Inside your strings.xml

<resources>
  <string name="server_client_id">Your Web Client Key ( Same as the one in the index.html meta tag )</string>
</resources>

Import package inside your MainActivity

import com.hristo2612.capacitor.google.auth;

Register plugin inside your MainActivity.java

public class MainActivity extends BridgeActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        registerPlugin(GoogleAuth.class);
    }
}

Configure

Provide configuration in root capacitor.config.json

{
  "plugins": {
    "GoogleAuth": {
      "scopes": ["profile", "email"],
      "serverClientId": "xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
      "forceCodeForRefreshToken": true
    }
  }
}

Note : forceCodeForRefreshToken force user to select email address to regenerate AuthCode used to get a valid refreshtoken (work on iOS and Android) (This is used for offline access and serverside handling)