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

Commit

Permalink
feat: oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
negebauer committed Jul 19, 2018
1 parent cf90633 commit 30de5c0
Show file tree
Hide file tree
Showing 142 changed files with 6,824 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ios/GithubPushNotificationsMobile.xcworkspace

# OSX
#
.DS_Store
Expand Down
55 changes: 54 additions & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import {Platform, StyleSheet, Text, View, Linking} from 'react-native';
import OAuthManager from 'react-native-oauth';

const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
Expand All @@ -16,8 +17,60 @@ const instructions = Platform.select({
'Shake or press menu button for dev menu',
});

const OAUTH_CONFIG = {
github: {
client_id: Platform.select({
ios: 'c8540af149a6bfe38a42',
android: '075e7aaa056d3cb2c1ff'
}),
client_secret: Platform.select({
ios: 'e4d6e5d8787d1acf145ecd8f53a92b4de25cf0c5',
android: '3ca8451b4da98a11f14fc4711f9b2dff327ba009'
}),
},
}

const OAUTH_APP_NAME = Platform.select({
ios: 'mobilegithubpushnotificationsios',
android: 'mobilegithubpushnotificationsandroid',
})

type Props = {};
export default class App extends Component<Props> {

constructor() {
super()
this.manager = new OAuthManager(OAUTH_APP_NAME)
console.log(this.manager);
}

componentDidMount() {
this.manager.configure(OAUTH_CONFIG);
console.log(this.manager);
Linking.addEventListener('url', this.handleOpenURL);
this.work()
}

componentWillUnmount() {
Linking.removeEventListener('url', this.handleOpenURL);
}

handleOpenURL = (event) => {
console.log(event.url);
}

work = async () => {
const { accounts } = await this.manager.savedAccounts()
console.log('account list: ', accounts);
// try {
// await this.manager.deauthorize('github')
// const { accounts: accounts2 } = await this.manager.savedAccounts()
// console.log('account list: ', accounts2);
// } catch (err) {}
const res = await this.manager.authorize('github', { scopes: 'notifications,read:user' })
console.log('res', res);
}

render() {
return (
<View style={styles.container}>
Expand Down
4 changes: 2 additions & 2 deletions android/app/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ android_library(

android_build_config(
name = "build_config",
package = "com.negebauer.githubPushNotificationsMobile",
package = "com.negebauer.GithubPushNotificationsMobile",
)

android_resource(
name = "res",
package = "com.negebauer.githubPushNotificationsMobile",
package = "com.negebauer.GithubPushNotificationsMobile",
res = "src/main/res",
)

Expand Down
3 changes: 2 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ android {
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
applicationId "com.negebauer.githubPushNotificationsMobile"
applicationId "com.negebauer.GithubPushNotificationsMobile"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
Expand Down Expand Up @@ -137,6 +137,7 @@ android {
}

dependencies {
compile project(':react-native-oauth')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.facebook.react:react-native:+" // From node_modules
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.negebauer.githubPushNotificationsMobile">
package="com.negebauer.GithubPushNotificationsMobile">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.negebauer.githubPushNotificationsMobile;
package com.negebauer.GithubPushNotificationsMobile;

import com.facebook.react.ReactActivity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.negebauer.githubPushNotificationsMobile;
package com.negebauer.GithubPushNotificationsMobile;

import android.app.Application;

import com.facebook.react.ReactApplication;
import io.fullstack.oauth.OAuthManagerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
Expand All @@ -22,7 +23,8 @@ public boolean getUseDeveloperSupport() {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
new MainReactPackage(),
new OAuthManagerPackage()
);
}

Expand Down
14 changes: 13 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ allprojects {
url 'https://maven.google.com/'
name 'Google'
}
maven { url "https://jitpack.io" }
}
}

Expand All @@ -36,5 +37,16 @@ ext {
minSdkVersion = 16
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
supportLibVersion = "26.0.1"
}

subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 26
buildToolsVersion '26.0.1'
}
}
}
}
2 changes: 2 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
rootProject.name = 'GithubPushNotificationsMobile'
include ':react-native-oauth'
project(':react-native-oauth').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-oauth/android')

include ':app'
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "GithubPushNotificationsMobile",
"displayName": "Github Notifications"
"displayName": "Github Push"
}
Loading

0 comments on commit 30de5c0

Please sign in to comment.