-
Notifications
You must be signed in to change notification settings - Fork 1
/
googleapi.form.ios.js
60 lines (52 loc) · 1.39 KB
/
googleapi.form.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
Modal,
TouchableHighlight,
WebView,
ListView,
} = React;
var urlparser = require('./urlparser');
var LoginView = React.createClass({
propTypes: {
client_id: React.PropTypes.string.isRequired,
onCode: React.PropTypes.func.isRequired,
},
onNavigationStateChange(navState) {
var parsed_url = urlparser.parse(navState.url);
if (parsed_url.path === 'http://localhost/') {
this.props.onCode(parsed_url.params.code);
}
},
render() {
var authorization_url
= 'https://accounts.google.com/o/oauth2/auth'
+ '?client_id=' + this.props.client_id
+ '&redirect_uri=' + 'http%3A%2F%2Flocalhost'
+ '&response_type=' + 'code'
+ '&scope=' + 'https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar'
+ '&access_type=' + 'offline';
return (
<WebView
url={authorization_url}
style={styles.webView}
automaticallyAdjustContentInsets={false}
javaScriptEnabledAndroid={true}
onNavigationStateChange={this.onNavigationStateChange}
renderError={this.renderError}
startInLoadingState={true}
scalesPageToFit={true}/>
);
}
});
var styles = StyleSheet.create({
webView: {
backgroundColor: 'rgba(255,255,255,0.8)',
height: 350,
},
});
module.exports = LoginView;