nativeScript-oauth

nativescriptcore

#1

Hello everyone. I’m trying to use nativeScript-oauth plugin in my project but the app crashes when I try to log in with facebook. I’m using plain javascript. How can I get to work.

app.js

var application = require("application");
var tnsOAuthModule = require("nativescript-oauth");


    //Initialise Nativescript Auth for facebook
    var facebookInitOptions = tnsOAuthModule.TnsOAuthOptionsFacebook = {
        clientId: 'MYAPPTID',
        clientSecret: 'MYAPPSECRET',
        scope: ['email']
    };
    tnsOAuthModule.initFacebook(facebookInitOptions);

application.start({moduleName: "signin"});

signin

var tnsOAuthModule = require("nativescript-oauth");
tnsOAuthModule.login();
.then(function(success){
        console.log('logged in');
        console.dir("accessToken " + tnsOAuthModule.accessToken());
    })
    .catch(function(er){
        console.log(er)
    });

#2

What does your crashlog says?

looks like you have an unexpected semicolon.


#3

This is the contents of the crashlog:


An uncaught Exception occurred on main thread.

com.tns.NativeScriptException: Java Error!

at com.tns.Runtime.callJSMethodNative(Native Method)

at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)

at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)

at com.tns.Runtime.callJSMethod(Runtime.java:912)

at com.tns.Runtime.callJSMethod(Runtime.java:896)

at com.tns.Runtime.callJSMethod(Runtime.java:888)

at com.tns.gen.android.webkit.WebViewClient_frnal_ts_helpers_l58_c38__TnsOAuthWebViewHelper.onReceivedError(WebViewClient_frnal_ts_helpers_l58_c38__TnsOAuthWebViewHelper.java:52)

at xf.a(SourceFile:284)

at afs.handleMessage(SourceFile:38)

at android.os.Handler.dispatchMessage(Handler.java:110)

at android.os.Looper.loop(Looper.java:203)

at android.app.ActivityThread.main(ActivityThread.java:6251)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Package.getName()' on a null object reference

at com.tns.Runtime.getTypeMetadata(Runtime.java:673)

at com.tns.Runtime.getTypeMetadata(Runtime.java:651)

... 15 more