B4J Question [SOLVED]OAuth integration

Alvaro MOnteiro

New Member
Licensed User
Longtime User
Hi, all.

I'm trying to integrate our management software to WooCommerce Rest API.
I'm using the OAuth B4A lib in B4J.
B4X:
Sub Process_Globals
    Dim req As HttpRequest
    Dim auth As OAuth
    ...
  
    Dim key As String = "myConsumerKey..........."
    Dim sec As String = "myConsumerSecret......"
    Dim url As String = "localhost/wp-json/wc/v2/products"
End Sub

Sub App_Start
    ...

    req.InitializeGet(url)
    auth.Initialize(key, sec)
    auth.Sign(req)

    ...

End Sub


When I call auth.Sign(req) B4J returns to me this exception:
oauth.signpost.exception.OAuthMessageSignerException: java.lang.NullPointerException

Looking in the Watcher, the Base64 in the messageSigner inside OAuth object is null. How can I set a value for it?
 

Alvaro MOnteiro

New Member
Licensed User
Longtime User
Can you post the full error message from the logs?

Hi, Erel!

This is the exception:



Waiting for debugger to connect...
Program started.
Error occurred on line: 30
oauth.signpost.exception.OAuthMessageSignerException: java.lang.NullPointerException
at oauth.signpost.signature.SignatureBaseString.generate(SignatureBaseString.java:61)
at oauth.signpost.signature.HmacSha1MessageSigner.sign(HmacSha1MessageSigner.java:52)
at oauth.signpost.AbstractOAuthConsumer.sign(AbstractOAuthConsumer.java:110)
at oauth.signpost.AbstractOAuthConsumer.sign(AbstractOAuthConsumer.java:120)
at anywheresoftware.b4a.objects.OAuth.Sign(OAuth.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:657)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
at b4j.example.main.start(main.java:38)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at oauth.signpost.signature.SignatureBaseString.normalizeRequestUrl(SignatureBaseString.java:67)
at oauth.signpost.signature.SignatureBaseString.generate(SignatureBaseString.java:55)
... 28 more
 
Upvote 0
Top