Skip to content

Instantly share code, notes, and snippets.

View spencercarli's full-sized avatar

Spencer Carli spencercarli

View GitHub Profile
@spencercarli
spencercarli / google-oauth.js
Created March 9, 2016 01:42
Connecting the Meteor and React Native Apps - google-oauth.js
// MeteorApp/server/google-oauth.js
const settings = Meteor.settings.google;
if (settings) {
ServiceConfiguration.configurations.remove({
service: 'google'
});
ServiceConfiguration.configurations.insert({
@spencercarli
spencercarli / settings.json
Created March 9, 2016 01:41
Connecting the Meteor and React Native Apps - settings.json
/* MeteorApp/settings.json */
{
"google": {
"client_secret": "MY_WEB_APP_SECRET",
"client_id": "MY_WEB_APP_CLIENT_ID",
"validClientIds": [
"MY_WEB_APP_CLIENT_ID",
"MY_IOS_APP_CLIENT_ID"
]
@spencercarli
spencercarli / signOut.js
Created March 9, 2016 01:37
Setup the React Native App - signOut.js
// RNApp/app/containers/signOut.js
import { GoogleSignin } from 'react-native-google-signin';
/*
Removed for brevity
*/
handleSignOut() {
// ddpClient.logout(() => {
// this.props.changedSignedIn(false);
@spencercarli
spencercarli / signIn.js
Created March 9, 2016 01:37
Setup the React Native App - signIn.js prt 5
// RNApp/app/containers/signIn.js
componentWillReceiveProps(nextProps) {
if (nextProps) {
GoogleSignin.currentUserAsync()
.then((user) => {
this.handleDDPSignIn(user)
})
.done();
}
@spencercarli
spencercarli / signIn.js
Created March 9, 2016 01:37
Setup the React Native App - signIn.js prt 4
// RNApp/app/containers/signIn.js
handleDDPSignIn(googleUser) {
if (googleUser) {
this.props.changedSignedIn(true);
}
}
/*
Removed for brevity
@spencercarli
spencercarli / signIn.js
Created March 9, 2016 01:36
Setup the React Native App - signIn.js prt 3
// RNApp/app/containers/signIn.js
button = <Button text="Sign In with Google" onPress={this.handleGoogleSignIn.bind(this)} />;
@spencercarli
spencercarli / signIn.js
Created March 9, 2016 01:36
Setup the React Native App - signIn.js prt 2
// RNApp/app/containers/signIn.js
import { GoogleSignin } from 'react-native-google-signin';
/*
Removed for brevity
*/
handleGoogleSignIn() {
GoogleSignin.signIn()
.then((user) => {
@spencercarli
spencercarli / signIn.js
Created March 9, 2016 01:36
Setup the React Native App - signIn.js
import React, {
Component,
StyleSheet,
Text,
View
} from 'react-native';
import Button from '../components/button';
import ddpClient from '../ddp';
@spencercarli
spencercarli / index.js
Created March 9, 2016 01:35
Setup the React Native App - index.js
// RNApp/app/index.js
import config from './config';
import { GoogleSignin } from 'react-native-google-signin';
/*
Removed for brevity
*/
componentWillMount() {
GoogleSignin.configure({
@spencercarli
spencercarli / config.js
Created March 9, 2016 01:35
Setup the React Native App - config.js
let opts = {
env: 'dev', // ['dev', 'staging', 'prod']
// codePushDeploymentKey: '',
ddpConfig: {
maintainCollections : true,
},
google: {
iosClientId: 'XYZ_YOUR_CLIENT_ID.apps.googleusercontent.com'
}
}