Skip to content

Instantly share code, notes, and snippets.

@Mattchewone
Last active January 11, 2019 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mattchewone/31dea6f34633bc086865ccb0876cf378 to your computer and use it in GitHub Desktop.
Save Mattchewone/31dea6f34633bc086865ccb0876cf378 to your computer and use it in GitHub Desktop.
basic react app
import React, { Component } from 'react'
import { StyleSheet, Text, View, Button } from 'react-native'
import { authorize } from 'react-native-app-auth'
const config = {
issuer: 'https://accounts.google.com',
clientId: 'SECRET',
redirectUrl: 'REDIRECT_URL',
scopes: ['openid', 'profile']
}
export default class App extends Component {
async _authorize () {
try {
// Make request to Google to get token
const authState = await authorize(config)
console.log({ authState })
} catch (error) {
console.log('error', error)
}
}
render () {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Button style={styles.login} onPress={this._authorize} title='Login' />
</View>
)
}
}
const styles = StyleSheet.create({ ... })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment