Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native-oauth module don't work with Expo. #70

Closed
ishowta opened this issue Oct 27, 2017 · 2 comments
Closed

react-native-oauth module don't work with Expo. #70

ishowta opened this issue Oct 27, 2017 · 2 comments

Comments

@ishowta
Copy link

ishowta commented Oct 27, 2017

I think that react-native-oauth module can't work with expo.

because react-native-oauth use NativeModules. react-native-oauth/lib/promisify.js

I tried this test code,

import React from 'react';
import { Button } from 'react-native';
import OAuthManager from 'react-native-oauth';

export default class App extends React.Component {

  _auth(){
    console.log('press auth');
    const manager = new OAuthManager('example')
    manager.configure({
      twitter: {
        consumer_key: '***',
        consumer_secret: '***'
      }
    });
    manager.authorize('twitter')
      .then(resp => console.log(resp))
      .catch(err => console.log(err));
  }

  render() {
    return (
      <Button title="Auth" onPress={this._auth} />
    );
  }
}

then an error occurred. It seems to be because of can't import NativeModules.

infoLog.js:17 Running application "main" with appParams: {"rootTag":1,"initialProps":{"exp":{"manifest":{"description":"An empty new project","packagerOpts":{"lanType":"ip","minify":false,"strict":false,"urlRandomness":"sg-8xx","hostType":"lan","urlType":"exp","dev":true},"debuggerHost":"192.168.10.4:19001","bundleUrl":"http://192.168.10.4:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&strict=false&minify=false&hot=false&assetPlugin=/home/saho/project/test3/node_modules/expo/tools/hashAssetFiles","slug":"test3","icon":"./assets/icon.png","primaryColor":"#cccccc","isVerified":true,"name":"test3","xde":true,"version":"1.0.0","iconUrl":"http://192.168.10.4:19001/assets/./assets/icon.png","id":"@ishowta/test3","orientation":"portrait","sdkVersion":"22.0.0","ios":{"supportsTablet":true},"env":{},"logUrl":"http://192.168.10.4:19000/logs","privacy":"public","mainModuleName":"node_modules/expo/AppEntry","developer":{"projectRoot":"/home/saho/project/test3","tool":"exp"},"splash":{"resizeMode":"contain","backgroundColor":"#ffffff","image":"./assets/splash.png","imageUrl":"http://192.168.10.4:19001/assets/./assets/splash.png"}},"appOwnership":"expo","initialUri":"exp://192.168.10.4:19000","shell":false}}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
App.js:8 press auth
App.js:18 TypeError: Cannot read property 'authorize' of undefined
    at promisify.js:11
    at tryCallTwo (core.js:45)
    at doResolve (core.js:200)
    at new Promise (core.js:66)
    at promisify.js:6
    at OAuthManager.authorize (react-native-oauth.js:44)
    at Object._auth (App.js:16)
    at Object.proxiedMethod [as onPress] (createPrototypeProxy.js:44)
    at Object.touchableHandlePress (TouchableOpacity.js:127)
    at Object._performSideEffectsForTransition (Touchable.js:746)
YellowBox.js:78 Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'configureProvider' of undefined
TypeError: Cannot read property 'configureProvider' of undefined
    at http://192.168.10.4:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&strict=false&minify=false&hot=false&assetPlugin=/home/saho/project/test3/node_modules/expo/tools/hashAssetFiles:95420:53
    at tryCallTwo (http://192.168.10.4:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&strict=false&minify=false&hot=false&assetPlugin=/home/saho/project/test3/node_modules/expo/tools/hashAssetFiles:16515:5)
    at doResolve (http://192.168.10.4:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&strict=false&minify=false&hot=false&assetPlugin=/home/saho/project/test3/node_modules/expo/tools/hashAssetFiles:16654:13)
    at new Promise (http://192.168.10.4:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&strict=false&minify=false&hot=false&assetPlugin=/home/saho/project/test3/node_modules/expo/tools/hashAssetFiles:16536:3)
    at http://192.168.10.4:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&strict=false&minify=false&hot=false&assetPlugin=/home/saho/project/test3/node_modules/expo/tools/hashAssetFiles:95413:12
    at OAuthManager.configureProvider (http://192.168.10.4:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&strict=false&minify=false&hot=false&assetPlugin=/home/saho/project/test3/node_modules/expo/tools/hashAssetFiles:95365:59)
    at http://192.168.10.4:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&strict=false&minify=false&hot=false&assetPlugin=/home/saho/project/test3/node_modules/expo/tools/hashAssetFiles:95374:23
    at Array.map (<anonymous>)
    at OAuthManager.configureProviders (http://192.168.10.4:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&strict=false&minify=false&hot=false&assetPlugin=/home/saho/project/test3/node_modules/expo/tools/hashAssetFiles:95373:51)
    at OAuthManager.configure (http://192.168.10.4:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&strict=false&minify=false&hot=false&assetPlugin=/home/saho/project/test3/node_modules/expo/tools/hashAssetFiles:95268:19)
console.warn @ YellowBox.js:78
onUnhandled @ Promise.js:35
onUnhandled @ rejection-tracking.js:71
(anonymous) @ JSTimers.js:256
_callTimer @ JSTimers.js:148
callTimers @ JSTimers.js:405
__callFunction @ MessageQueue.js:306
(anonymous) @ MessageQueue.js:108
__guard @ MessageQueue.js:269
MessageQueue.callFunctionReturnFlushedQueue @ MessageQueue.js:107
(anonymous) @ debuggerWorker.js:72
@jimmylee
Copy link
Collaborator

Thanks for surfacing this, I'm going to give it a test run myself and if its true then I'll remove the libraries Expo compatibility.

Really appreciate you bringing this up, its people like you that help me keep everything up to date. <3

@jimmylee
Copy link
Collaborator

So you're right, it doesn't work with Expo, and it was my fault that it was listed as working with Expo. I'm so sorry about any trouble this has caused you!

Meanwhile, if you need an auth service, I recommend you check out this code example: "https://github.com/expo/auth0-example"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants