React-native-app-auth: RNAppAuth Object is undefined.

Created on 10 Jul 2018  路  18Comments  路  Source: FormidableLabs/react-native-app-auth

I think something is broken with your library.

OS: Android
Functionality: authorize

Where RNAppAuth is defined: 
- index.js@L4 ( const { RNAppAuth } = NativeModules) 

React Native Version: 0.38
React-Native-App-Auth: "^2.6.1"

Whenever I try to call the authorize function with the proper credentials, it returns a:

"Calling an undefined property authorize" error. 

Logging out the RNAuthApp object, I discovered that indeed the RNAuthApp object is undefined!
This means there's either NativeModules being included is incorrect.

Solutions I've tried:

  • react-native linked the library already.
  • I've restarted my running server to purge any "cached?" elements.

Does anyone else have this problem? Should I be diving deeper into why NativeModules is undefined?

Most helpful comment

Hi @mafelix - sorry you happened to try the library at the awkward time when the docs were out of date with the latest release.

I've just published v3.0.0. Could you please try again with the latest version 馃檹

All 18 comments

Hi @mafelix - sorry you happened to try the library at the awkward time when the docs were out of date with the latest release.

I've just published v3.0.0. Could you please try again with the latest version 馃檹

Thank you so much @kadikraman! I'll try the updated version soon.

@mafelix I just read your issue again and v3 affects iOS, not really Android. If it's still not working for you, could you try cloning this repo and running the Example project to see if you get the same error?

@kadikraman I believe it is related to my react-native version (0.38).

I unlinked, and uninstalled the package and reinstalled the new react-native-app-auth(3.0+) version and relinked and I got the same error.

Undefined property authorize

Now I will run your example project with react-native version (0.50.1)

If this is the problem, can you include RN dependencies in the docs?

@kadikraman so after some weird issues with node_modules and making sure npm packages have all their peer dependencies met, the example works.

But what I am doing is sending to a request to a custom oAuth2.0, it's not any of the big oAuth services(Twitter, Instagram, Facebook, etc).

This is possible with this library correct? What are the dependency requirements for this library?

Yes, it should work with any OAuth client, given they have implemented the OAuth spec correctly. RN 38 is quite old, it鈥檚 possible that the bridging API would have changed and is not backwards compatible. 50 is the oldest version I鈥檝e tested with 馃槙

It鈥檚 a very good point though, I should definitely find out the lowest version this works with. At the moment I鈥檓 only confident that it鈥檚 50+

I think this may be related to #113, this is the error I am getting on iOS with react-native 0.55.4

That error just means that your app can't find the RNAppAuth module, so something's gone wrong either in the configuration, e.g. forgetting to run react-native link.

Same here on Android. Already linked the library and cleared the cache. Is there any update on this?

It should work, I'm not sure why you're having this issue. Would you be able to create an example RN project where you get this error so I could look into it?

It worked on 56.0, but not 55.4

Actually, I installed the 1.0.1 version an followed a tutorial and now it works. I don't know if it is some issue with the new version, but the problem is solved for me. React Native running is on 0.55.4.

Hmm. Is there any way to expose the error messages from the request? Trying to debug why I am not receiving a token for the authorize method but all I get is a generic Failed to authenticate error.

@kadikraman Question, is there way to make a background fetch for the oauth token instead of sliding a web viewer modal onto the screen?

Edit:
Nevermind, I believe if you don' t pass in the authorization property to the service configuration object then there's no modal that slides over. I don't need to include all properties in service configuration object right?

Closing this as I don't think it's an issue in the latest versions of the library. Please reopen if it's still a problem.

@kadikraman I believe this should be reopened. I was unable to get this working at all unfortunately.

I just did the following steps and received the same error:

  • react-native init
  • yarn add react-native-app-auth (v4.0.0)
  • react-native link react-native-app-auth
  • ensured that the correct configurations were set from the setup guide in the README

This still results in an error that it cannot read property authorize on RNAppAuth.

@mjniday please check out our Examples directory. There are examples there for iOS (both using Pods and Carthage) and Android.

Might also be worth noting that you're need to rebuild the native app after adding the library (react-native run-ios or react-native run-android)

Weird if I launch the app by using .xcworkspace I got no problem, but if I launch with RN cli react-native run-ios I keep getting this error, and I definitely run react-native link react-native-app-auth

I finally get it resolved by delete the ios app and do react-natve eject and follow the guides all over again...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

djleonskennedy picture djleonskennedy  路  3Comments

pikooli picture pikooli  路  4Comments

Solitaryo picture Solitaryo  路  8Comments

kadikraman picture kadikraman  路  3Comments

janpieterz picture janpieterz  路  4Comments