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

react-native-simple-google-login

v0.0.2

Published

A `<GoogleLogin />` component for react-native no native code added light weight library to make user Google login. No setup, no linking required, use it like a component.

Downloads

6

Readme

react-native-simple-google-login

npm (tag) PRs Welcome GitHub top language David publish size

A <GoogleLogin /> component for react-native no native code added light weight library to make user Google login. No setup, no linking required,use it like a component.

This module uses Google OAuth2.

Installation

npm i --save react-native-simple-google-login

or

yarn add react-native-simple-google-login

Linking

As this module uses react-native-webview react-native-webview as dependencies, it's required to link them at the moment.

react-native link react-native-webview
react-native link @react-native-community/async-storage

TODO: Making the them automate

Setup Instructions

  1. Go to the Google Developers Console
  2. Select your project or create a new one (and then select it)
  3. Create a service account for your project
  • In the sidebar on the left, expand APIs & auth > Credentials
  • Click blue "Add credentials" button
  • Select the "OAuth client ID" option
  • Select the "other" key type option
  • Click blue "Create" button
  • Save the Client_id, that's all you need (it is the only copy!)

Props

| name | desc | type | default | --- | --- | --- | --- | | credentialsDetails | Google client details | object | {redirectUrl: '', clientId:''} | scope | scope for the login which will be included in access token | string | 'profile email openid' | getAccessToken | Callback for access token when token received | function | undefined | getUserDetails | Callback for user details when received | function | undefined

Usage

import React, { useState } from 'react';
import GoogleLogin, { getCurrentUser, getToken, getStatus, revokeAccess } from 'react-native-simple-google-login';

export default function App() {
  const clientId = 'YOUR_CLIENT_ID';
  const GOOGLE_REDIRECT_URI = 'http://localhost';
  const [ isLoggedIn, setLoggedIn ] = useState(false);

  function _onPressLoginButton() {
    if(isLoggedIn) {
      //do something else
    } else {
      setLoggedIn(true);
    }
  }

  function getAccessToken(token) {
      console.log(token, 'User logged in, token received');
      setLoggedIn(false);
  }

  function getUserDetails(data) {
      console.log(data, 'User details received');
  }

  function _onPressDetailsButton() {
    getCurrentUser().then(userDetails => {
      console.log(userDetails, 'stored user details in async storage');
    });
  }

  return (
    <View style={{flex: 1}}>
      <GoogleLogin
        credentialsDetails={{
          redirectUrl: GOOGLE_REDIRECT_URI,
          clientId,
        }}
        getAccessToken={getAccessToken}
        getUserDetails={getUserDetails}
      />
      <TouchableOpacity onPress={_onPressLoginButton}>
        <Text>Login with Google</Text>
      </TouchableOpacity>
      <TouchableOpacity onPress={_onPressDetailsButton}>
        <Text>Get user details</Text>
      </TouchableOpacity>
    </View>
  )
}

Docs

Exposed data: userDetails, accessToken, sessionValid | name | desc | type | default | --- | --- | --- | --- | | getCurrentUser | Details of user logged in | Promise | null | getToken | Access token after logged in | Promise | null | getStatus | Returns a bool value which can be checked if the user is already logged in | Promise | null | revokeAccess | Remove your application from the user authorized applications. | Promise | null

Dependency

react-native-webview react-native-webview

Contribute

Help to make it better! Please see CONTRIBUTING.md for more details.

License


MIT License