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-meteor-oauth

v0.1.0

Published

OAuth login to a Meteor back-end from React Native

Downloads

6

Readme

react-native-meteor-oauth

Oauth2 login to a Meteor server in React Native

How?

import React, { Component } from 'react'
import View from 'react-native'
import Meteor from 'react-native-meteor'
import Login from 'react-native-meteor-oauth'

const meteorHost = '192.168.1.73:3000' // Put your local IP here if running in dev
Meteor.connect(`ws://${meteorHost}/websocket`)

export default () => {
  return (<View>
    <Login
      provider='Github'
      callbackUrl='http://localhost:3000/_oauth/github'
      meteorServerDomain={meteorHost}
      meteorServerProtocol='http'
      clientId='YOUR_GITHUB_CLIENT_ID'
    />
  </View>)
}

This module depends on react-native-meteor under the hood, which should then be used for subscriptions, method calling and so on once login has occurred.

The react-native-meteor docs specify that you should Meteor.connect only once in your app's parent component. The example above is reductive, but in a more realistic app this would involve having the Meteor.connect line in the parent component and requiring/using react-native-meter-oauth in subcomponents.

Which providers are supported?

Currently: Github, Google and Facebook.

Any other provider which allow login with Oauth2 can easily be added, which unfortunately does not presently include Twitter.

Props

  • provider (required): one of ["Github", "Google", "Facebook"] for automatic config, but can be anything if you supply url and possibly extraRequestParam (see below).
  • clientId (required): the client ID given by the OAuth provider.
  • callbackUrl (required): the callback URL you specified to the OAuth provider corresponding to this clientId.
  • meteorServerDomain (required): the domain of the Meteor server you're intending to log in to. Note localhost:3000 will not work here, as a device (even running in an emulator) has to connect over the (local) network. Use your dev server's local IP in dev.
  • meteorServerProtocol (required): either http or https.
  • scope (optional): a space-delimited string of requested scopes. Sensible but limited defaults are provided.
  • url (optional): the url you want to use to request authorization from the OAuth provider. Theoretically, this (along with the param below) allows you to connect to any arbitary provider.
  • extraRequestParams (optional): a dictionary of extra parameters which need to be provided in the authorization request to make OAuth work. For example, Google requires response_type="code", but this is already set by default.
  • styles (optional): a dictionary of styles to overwrite the defaults, which are as follows:
{
  buttonContainer: { flexDirection: 'row', justifyContent: 'space-around' },
  button: { flex: -1 },
  buttonLogin: { backgroundColor: '#bbb'},
  buttonLogout: { backgroundColor: '#bbb'},
  buttonLoginText: { textAlign: 'center', paddingVertical: 12, paddingHorizontal: 40 },
  buttonLogoutText: { textAlign: 'center', paddingVertical: 12, paddingHorizontal: 40 },
  text: { textAlign: 'center', marginBottom: 15 },
  view: { flex: 1, alignSelf: 'stretch', justifyContent: 'center' }
}

Provider-specific styles are also merged into these for the Github, Google and Facebook.