Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
Feat(master): Add all private key by API in app.json instead of put b…
Browse files Browse the repository at this point in the history
…y hand in the js file + add few security for these data + radius header was remastered.
  • Loading branch information
simonprovost committed Aug 11, 2019
1 parent 6a8b71a commit 6d539da
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .expo/packager-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"expoServerPort": null,
"packagerPort": null,
"packagerPid": null,
"expoServerNgrokUrl": null,
"packagerNgrokUrl": null,
"ngrokPid": null
"expoServerNgrokUrl": "https://gm-rib.simonprovost.socialcard.exp.direct",
"packagerNgrokUrl": "https://packager.gm-rib.simonprovost.socialcard.exp.direct",
"ngrokPid": 25041
}
40 changes: 38 additions & 2 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {StatusBar,
StyleSheet,
Alert,
CameraRoll,
BackHandler
} from 'react-native';
import Swiper from 'react-native-swiper'
import {FacebookScreen} from "./screens/facebook";
Expand All @@ -17,6 +18,8 @@ import * as Permissions from 'expo-permissions';
import FlashMessage from "react-native-flash-message";
import { showMessage, hideMessage } from "react-native-flash-message";
import {Header, Text} from "react-native-elements"
import * as dataConstants from './app.json';


export default class App extends Component {

Expand All @@ -30,7 +33,40 @@ export default class App extends Component {
};
}

async componentDidMount() {
async componentDidMount(title, message) {
if (
dataConstants.expo.extra.facebook.appId === undefined ||
dataConstants.expo.extra.instagram.clientID === undefined ||
dataConstants.expo.extra.instagram.redirectURI === undefined ||
dataConstants.expo.extra.linkedin.clientID === undefined ||
dataConstants.expo.extra.linkedin.clientSecret === undefined ||
dataConstants.expo.extra.linkedin.redirectURI === undefined ||
dataConstants.expo.extra.twitter.consumerKey === undefined ||
dataConstants.expo.extra.twitter.consumerKeySecret === undefined ||
dataConstants.expo.extra.facebook.appId === "" ||
dataConstants.expo.extra.instagram.clientID === "" ||
dataConstants.expo.extra.instagram.redirectURI === "" ||
dataConstants.expo.extra.linkedin.clientID === "" ||
dataConstants.expo.extra.linkedin.clientSecret === "" ||
dataConstants.expo.extra.linkedin.redirectURI === "" ||
dataConstants.expo.extra.twitter.consumerKey === "" ||
dataConstants.expo.extra.twitter.consumerKeySecret === ""
) {
Alert.alert(
'Social card APP INFO',
'Data for API was not found (ios you can exit by hand the app)',
[
{text: 'How to solved it ?', onPress: () => {
Alert.alert('Social Card APP INFO', 'Open app.json to configure the data for api', [
{text: 'OK', onPress: () => BackHandler.exitApp()}
])
}},
{text: 'OK', onPress: () => BackHandler.exitApp()},
],
{cancelable: false},
);
}

await Font.loadAsync({
Roboto: require("native-base/Fonts/Roboto.ttf"),
Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf"),
Expand Down Expand Up @@ -124,7 +160,7 @@ export default class App extends Component {
height: "10%",
borderBottomRightRadius: 60,
borderBottomLeftRadius: 60,
}}
}}get
/>
<Swiper
showsPagination={true}
Expand Down
17 changes: 13 additions & 4 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@
"supportsTablet": true
},
"extra": {
"twitter": {
"consumerKey": "sIaBRZBbihUabSRkENZUjWL2e",
"consumerKeySecret": "u6qePkEENXuI5zttzFMYzIL335JBAGq38kpF8FGzptVgBt1CvB"
"facebook": {
"appId": ""
},
"instagram": {
"clientId": "d934c0bd06694d9eb3c0625d26ee39b9"
"clientID": "",
"redirectURI": ""
},
"linkedin": {
"clientID": "",
"clientSecret": "",
"redirectURI": ""
},
"twitter": {
"consumerKey": "",
"consumerKeySecret": ""
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"react-native-clean-project": "^3.2.4",
"react-native-element": "^1.2.1",
"react-native-elements": "^1.1.0",
"react-native-exit-app": "^1.0.0",
"react-native-flash-message": "^0.1.13",
"react-native-instagram-login": "^1.1.1",
"react-native-linkedin": "^1.3.2",
Expand Down
20 changes: 18 additions & 2 deletions screens/facebook.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, {Component } from "react";
import * as Facebook from "expo-facebook";
import {Button, Container, Text, View, Thumbnail, Body} from "native-base";
import {Button, Container, Text, View, Thumbnail, Body, Root} from "native-base";
import {GenericRoundedCard} from "../components/genericRoundedCard";
import {StyleSheet, TouchableOpacity, } from "react-native";
import { showMessage, hideMessage } from "react-native-flash-message";
import * as dataConstants from './../app.json';
import {AppLoading} from "expo";

export class FacebookScreen extends Component {
constructor(props) {
Expand All @@ -14,10 +16,16 @@ export class FacebookScreen extends Component {
picture: null,
email: null,
socialNetworkConnected: false,
appId: null,
};
this.logInFacebook = this.logInFacebook.bind(this);
}

componentDidMount() {
this.setState({appId: dataConstants.expo.extra.facebook.appId,
loading: false})
}

async logInFacebook() {
try {
const {
Expand All @@ -26,7 +34,7 @@ export class FacebookScreen extends Component {
expires,
permissions,
declinedPermissions,
} = await Facebook.logInWithReadPermissionsAsync('2445401388871908', {
} = await Facebook.logInWithReadPermissionsAsync(this.state.appId, {
permissions: ['public_profile', 'email',],
});
if (type === 'success') {
Expand Down Expand Up @@ -61,6 +69,14 @@ export class FacebookScreen extends Component {
}

render() {
if (this.state.loading) {
return (
<Root>
<AppLoading
/>
</Root>
);
}
let facebookCard = this.state.socialNetworkConnected ?
<View style={{flex: 1, }}>
<View style={styles.container}
Expand Down
27 changes: 24 additions & 3 deletions screens/instagram.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, {Component } from "react";
import * as Facebook from "expo-facebook";
import {Button, Container, Text, View} from "native-base";
import {Button, Container, Root, Text, View} from "native-base";
import {GenericRoundedCard} from "../components/genericRoundedCard";
import {StyleSheet} from "react-native";
import InstagramLogin from "react-native-instagram-login";
import {showMessage} from "react-native-flash-message";
import * as dataConstants from './../app.json';
import {AppLoading} from "expo";

export class InstagramScreen extends Component {
constructor(props) {
Expand All @@ -16,9 +18,19 @@ export class InstagramScreen extends Component {
followingInstagram: 0,
followersInstagram: 0,
socialNetworkConnected: false,
redirectURI: null,
clientID: null,
};
}

componentDidMount() {
this.setState({
clientID: dataConstants.expo.extra.instagram.clientID,
redirectURI: dataConstants.expo.extra.instagram.redirectURI,
loading: false,
})
}

addInstagramInfoUser = (data) => {
this.setState({pseudoInstagram: data.data.username, followingInstagram: data.data.counts.follows,
followersInstagram: data.data.counts.followed_by, socialNetworkConnected: true})
Expand All @@ -45,6 +57,15 @@ export class InstagramScreen extends Component {


render() {
if (this.state.loading) {
return (
<Root>
<AppLoading
/>
</Root>
);
}

let instaCard =
this.state.socialNetworkConnected ?
<View style={{flex: 1,}}>
Expand Down Expand Up @@ -168,8 +189,8 @@ export class InstagramScreen extends Component {
</Button>
<InstagramLogin
ref= {ref => this.instagramLogin= ref}
clientId='b6593dc2f7c94d51a0faf65b1d3c0093'
redirectUrl='https://google.com'
clientId={this.state.clientID}
redirectUrl={this.state.redirectURI}
scopes={['basic']}

onLoginSuccess={(token) => {
Expand Down
32 changes: 27 additions & 5 deletions screens/linkedin.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, {Component} from "react";
import {Button, Container, Text, View} from "native-base";
import {Button, Container, Root, Text, View} from "native-base";
import {GenericRoundedCard} from "../components/genericRoundedCard";
import {StyleSheet} from "react-native";
import LinkedInModal from "react-native-linkedin";
import {showMessage} from "react-native-flash-message";
import * as dataConstants from './../app.json';
import {AppLoading} from "expo";

export class LinkedinScreen extends Component {
constructor(props) {
Expand All @@ -12,10 +14,21 @@ export class LinkedinScreen extends Component {
loading: true,
linkedinConnected: false,
socialNetworkConnected: false,

clientID: null,
clientSecret: null,
redirectURI: null,
};
}

componentDidMount() {
this.setState({
clientID: dataConstants.expo.extra.linkedin.clientID,
clientSecret: dataConstants.expo.extra.linkedin.clientSecret,
redirectURI: dataConstants.expo.extra.linkedin.redirectURI,
loading: false,
})
}

async getUserInfoIn({ access_token }) {
this.setState({ refreshing: true });
const baseApi = 'https://api.linkedin.com/v2/me/';
Expand All @@ -40,6 +53,15 @@ export class LinkedinScreen extends Component {
}

render() {
if (this.state.loading) {
return (
<Root>
<AppLoading
/>
</Root>
);
}

let inCard =
this.state.linkedinConnected ?
<View style={{flex: 1,}}>
Expand Down Expand Up @@ -128,9 +150,9 @@ export class LinkedinScreen extends Component {
ref={ref => {
this.modal = ref
}}
clientID={"86vmluha5e73ou"}
clientSecret={"Q6p5Ft46YLlg2u6F"}
redirectUri="https://www.google.fr/"
clientID={this.state.clientID}
clientSecret={this.state.clientSecret}
redirectUri={this.state.redirectURI}
onSuccess={data => {
this.getUserInfoIn(data);
showMessage({
Expand Down
3 changes: 2 additions & 1 deletion screens/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {AsyncStorage, StyleSheet} from "react-native";
import twitter, {TWLoginButton} from "react-native-simple-twitter";
import {AppLoading} from "expo";
import { showMessage, hideMessage } from "react-native-flash-message";
import * as dataConstants from './../app.json';

export class TwitterScreen extends Component {
constructor(props) {
Expand All @@ -22,7 +23,7 @@ export class TwitterScreen extends Component {

async componentDidMount() {
loadResourcesAsync = async () => Promise.all([
twitter.setConsumerKey("sIaBRZBbihUabSRkENZUjWL2e","u6qePkEENXuI5zttzFMYzIL335JBAGq38kpF8FGzptVgBt1CvB"),
twitter.setConsumerKey(dataConstants.expo.extra.twitter.consumerKey,dataConstants.expo.extra.twitter.consumerKeySecret),
]);
this.setState({loading: false});
}
Expand Down

0 comments on commit 6d539da

Please sign in to comment.