I'm using react-native-oauth
and getting this error (see red image at bottom) when trying to authorise. I've searched and found only this similar unanswered question. I looked into the source and found where the error is raised on line 954 and it seems it's because moduleIDs.count
should equal methodIDs.count
and paramsArrays.count
:
if (RCT_DEBUG && (moduleIDs.count != methodIDs.count || moduleIDs.count != paramsArrays.count)) {
RCTLogError(@"Invalid data message - all must be length: %zd", moduleIDs.count);
So, still in the source, I look for these objects and find them defined just above, on lines 943-945 and they are using RCTConvert, whose functions "...all accept a JSON value as input and map it to a native Objective-C type or class." - React's docs
So it seems like this is a transpiling and/or networking related error. But I have basically 0 knowledge on those fields and feel I've hit a barrier to investigating and wondered if anybody had any ideas on moving forward. Being new to React Native and never having done any Objective-C can't be helping me.
Also, here's my code generating the errors.
import OAuthManager from 'react-native-oauth';
import {
Alert
} from 'react-native'
var env = require('../environment.js')
const config = {
facebook: {
client_id: env.getKey("FB_ID"),
client_Secret: env.getKey("FB_SECRET")
}
}
const manager = new OAuthManager('myAppName')
manager.configure(config);
exports.authWithFb = () => {
manager.authorize('facebook')
.then(resp => Alert.alert('response!' + resp))
.catch(err => Alert.alert('error msg here: ' + err));
}
I am guessing this undefined error is related to the RCTBridge error but not sure. You can below see when I Alert the manager.authorize
's caught error. TypeError: undefined is not an object (evaluating 'fn')
:
Edit:
When I try to Alert the config
object, I get an error about not being able to stringify it's sub-object.
When looking in console in chrome debugger, I get "Cannot read property 'configureProvider' of undefined" and configureProvider()
is what react-native-oauth
uses so it looks like the manager is not set up right so maybe I didn't link the library well. Have checked the linking worked.
Im digging into the errors a bit and it seems like a promise/callback related problem from NativeModules.OAuthManager
. The error caught is: TypeError: Cannot read property 'authorize' of undefined
. When I jump into the stack trace I find:
Any help is much appreciated, thanks.
You'll get this error when you will send some wrong data into native side. For example if you should pass string but you passed an object.
Please console.log your
config
variable.https://www.npmjs.com/package/react-native-oauth
I guess you're sent some wrong data into native side