Java NullPointerException null when calling forge.ajax - trigger.io

When calling forge.ajax and request returns a 401 with JSON, under Android only (both device and emulator) I'm getting the following error message:
[ INFO] D/Forge (25373): Returning: {"content":{"type":"UNEXPECTED_FAILURE","message":"Forge Java error: NullPointerException: null","full_error":"java.lang.NullPointerException\n\tat io.trigger.forge.android.modules.request.API$1$1.getPasswordAuthentication(API.java:107)\n\tat java.net.Authenticator.requestPasswordAuthentication(Authenticator.java:140)\n\tat libcore.net.http.HttpURLConnectionImpl.getAuthorizationCredentials(HttpURLConnectionImpl.java:432)\n\tat libcore.net.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:407)\n\tat libcore.net.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:356)\n\tat libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:292)\n\tat libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)\n\tat io.trigger.forge.android.modules.request.API$1.run(API.java:285)\n\tat io.trigger.forge.android.core.ForgeTask$1.doInBackground(ForgeTask.java:112)\n\tat android.os.AsyncTask$2.call(AsyncTask.java:287)\n\tat java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:137)\n\tat android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)\n\tat java.lang.Thread.run(Thread.java:856)\n"},"status":"error","callid":"46C2A570-7229-4427-9BF8-F64FB12F6D8F"}
The forge.ajax error callback is being fired but the error.content object contains the string above and does not have the response.
Notice that this is not happening on iOS.
You can see this in action when running the app from the play store and trying to login with a wrong password/non existing user.
Full source code is available on github

This arose when attempting to access HTTP resources protected with basic auth, and no username was supplied to request.ajax.
The bug was fixed in v1.4.24 of the platform - sorry for the inconvenience!
http://docs.trigger.io/en/v1.4/release-notes.html#v1-4-24

Related

Google One Tap throws error with cryptic message

After implementing Google One Tap I noticed some JS errors on the client side (these client-side errors are caught in the browser and sent to the backend; I can see them in the backend logs but cannot reproduce the issue in the client side) for which the stack trace looks like this:
Error: A
at Object._.ad (/_/gsi/_/js/k=gsi.gsi.en_US.PmiGgqd91Pc.O/am=CQ/d=1/ct=zgms/rs=AF0KOtWwHiXCDsPbTZybnAb2zlX1YPJDGg/m=gis_client_library:109:138)
at /_/gsi/_/js/k=gsi.gsi.en_US.PmiGgqd91Pc.O/am=CQ/d=1/ct=zgms/rs=AF0KOtWwHiXCDsPbTZybnAb2zlX1YPJDGg/m=gis_client_library:299:24
at He.<anonymous> (/_/gsi/_/js/k=gsi.gsi.en_US.PmiGgqd91Pc.O/am=CQ/d=1/ct=zgms/rs=AF0KOtWwHiXCDsPbTZybnAb2zlX1YPJDGg/m=gis_client_library:241:164)
at uc (/_/gsi/_/js/k=gsi.gsi.en_US.PmiGgqd91Pc.O/am=CQ/d=1/ct=zgms/rs=AF0KOtWwHiXCDsPbTZybnAb2zlX1YPJDGg/m=gis_client_library:87:200)
at He._.l.dispatchEvent (/_/gsi/_/js/k=gsi.gsi.en_US.PmiGgqd91Pc.O/am=CQ/d=1/ct=zgms/rs=AF0KOtWwHiXCDsPbTZybnAb2zlX1YPJDGg/m=gis_client_library:85:347)
at Be (/_/gsi/_/js/k=gsi.gsi.en_US.PmiGgqd91Pc.O/am=CQ/d=1/ct=zgms/rs=AF0KOtWwHiXCDsPbTZybnAb2zlX1YPJDGg/m=gis_client_library:179:210)
at Fe (/_/gsi/_/js/k=gsi.gsi.en_US.PmiGgqd91Pc.O/am=CQ/d=1/ct=zgms/rs=AF0KOtWwHiXCDsPbTZybnAb2zlX1YPJDGg/m=gis_client_library:181:245)
at He._.l.zc (/_/gsi/_/js/k=gsi.gsi.en_US.PmiGgqd91Pc.O/am=CQ/d=1/ct=zgms/rs=AF0KOtWwHiXCDsPbTZybnAb2zlX1YPJDGg/m=gis_client_library:186:212)
at He._.l.Nb (/_/gsi/_/js/k=gsi.gsi.en_US.PmiGgqd91Pc.O/am=CQ/d=1/ct=zgms/rs=AF0KOtWwHiXCDsPbTZybnAb2zlX1YPJDGg/m=gis_client_library:186:187)
The JS code that throws this error is embedded in a <script> tag inside an <iframe> that displays the One Tap login popup and it seems to expect an AJAX response with a specific prefix; the statement that throws the error basically looks like this (minified JS):
if (!a.startsWith(")]}'\n")) throw console.error("malformed JSON response:", a), Error("A");
I checked the network requests and noticed that there is an XHR request that returns the response in this format; the endpoint is https://accounts.google.com/gsi/status (with some extra request parameters) but I cannot find any documentation from google for this endpoint.
Does anyone know would could be the cause of this error?
Thank you

com.microsoft.graph.http.GraphServiceException: Error code: SyncStateInvalid

com.microsoft.graph.http.GraphServiceException: Error code: SyncStateInvalid
Error message: The sync state identified using the request token 'HzWyBB6EZsMOpd9NmgmVnqAnVEMAAAQ9rM8FAwAA' is no longer valid.
GET https://graph.microsoft.com/v1.0/users/6be2c2df-8e20-4f99/mailFolders/AQMkADlmY2YxNTY3LWVhNjItNDFhMS1iZDA0LWZ/messages/microsoft.graph.delta?$deltatoken=LztZwWjo5IivWBhyxw5rAHNeTrUj6tmJCwsicW9zTkZhNFWO0u7VKvvdkBxQHWUvDsSPLMpUBSlb3nEcc_qVbTk1hQlWa3MIyqHvnT47wRA.NIA-bd_JnbZrpOuTHnjHoWWo1K5QPy4CLrFTODjYn9c
Prefer : odata.maxpagesize=1
Prefer : IdType="ImmutableId"
SdkVersion : graph-java/v1.6.0
Authorization : Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI[...]
Hi guys, I'm getting the above SyncStateInvalid error, I've done a search, realizing that most people are facing SyncStateNotFound error instead.
Not sure if anyone faces this issue before and knows what is the fix.
I am trying to sync incremental mail messages based on the delta token.
I've tried to paste the same link in graph explorer, and was able to get result.

OAuth 1.0b receiving access token

Until few days ago everything worked fine. But after some changes on FitBit new user can not get OAuth handshake anymore. The problem is when I receive temporary tokens and make call to finish handshake and receive credentials.
So in first step I get:
TOKEN: 1a227cfde686220183763946a98173bc and VERIFIER: p2g5ims7o4ffscev603rbif05g
and in second step I use theme to make call to https://api.fitbit.com/oauth/access_token ...
Signature Base String is:
POST&https%3A%2F%2Fapi.fitbit.com%2Foauth%2Faccess_token&oauth_consumer_key%3D7c5e888aa3dd4d17a26d82a7f541b278%26oauth_token%3D1a227cfde686220183763946a98173bc%26oauth_nonce%3D5hw45lgu%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1391094796%26oauth_verifier%3Dp2g5ims7o4ffscev603rbif05g%26oauth_version%3D1.0
And by that I receive header (with signature calculated using the same function as in first step)
Authorizing with HEADER: OAuth oauth_consumer_key="7c5e888aa3dd4d17a26d82a7f541b278",oauth_token="1a227cfde686220183763946a98173bc",oauth_nonce="5hw45lgu",oauth_signature="X4udgn9A7Q2xI%2FN38QELl%2BIDVqM%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1391094796",oauth_verifier="p2g5ims7o4ffscev603rbif05g",oauth_version="1.0"
That should work but I get 401 error saying:
{"errors":[{"errorType":"oauth","fieldName":"oauth_access_token","message":"Invalid signature or token 'JNGSIMomid/oghtWGrz7crC6KhM=' or token '6c45d0ce39195e848da14cad0a4f9719'"}],"success":false}
I have been working od that for 7 hours now ... and as far as I can see everything is OK ... Error is saying about field name oauth_access_token ... This fields doesn't even exist. I tried anyway and recived error saying that security is not OK ...
Any Idea?
I had the same problem. After doing some research I noticed that the API has changed and the lib I was using was out dated.
To fix that, I updated my lib and did some code changes.
Here is the link of a .Net implementation after the change:
https://github.com/aarondcoleman/Fitbit.NET/wiki/Breaking-Change-on-1-24-2014-as-a-result-of-OAuth-update-in-Fitbit-API
Regards,
Fredy

Grails Rest Client Builder POST Return Error/Exception

I've been working with the grails plugin: 'grails-rest-client-builder:2.0.1'
https://github.com/grails-plugins/grails-rest-client-builder/
I'm experiencing an odd issue when I POST some data to a web service, a 500 Exception, even though the POST indeed is working successfully.
Class
java.lang.NoClassDefFoundError
Message
org/springframework/util/StreamUtils
Around line 195 of PageFragmentCachingFilter.java
if (CollectionUtils.isEmpty(cacheOperations)) {
log.debug("No cacheable annotation found for {}:{} {}"
new Object[] { request.getMethod(), request.getRequestURI(), getContext() });
chain.doFilter(request, response);
return;
}
The response that is coming back from the web service should look like this:
{"id":"9999","key":"IX-2247","self":"https://jira.xxxx.com/rest/api/latest/issue/9999"}
Again, the web service is correctly getting the values that I pass into it, and I verified this by checking the application that I'm posting to and I do see what I expect. Not only that, but I also receive an email from the system that I am POSTing to, and the email contains the correct values from the Grails application.
Here's the POST that I'm using:
def rest = new grails.plugins.rest.client.RestBuilder()
def resp = rest.post("https://jira.xxxx.com/rest/api/latest/issue/"){
auth "Basic xxxx"
contentType "application/json"
json builder.toPrettyString()
}
My hypothesis is that perhaps the issue is that the rest-client-builder is having some kind of issue with the response that is being returned from the web service.
Has anyone encountered anything like this before, where the service is working, but Grails throws a 500 error, even on a successful POST?
Please let me know if I need to provide additional information.
Thanks in advance!
Thank you all for the replies. I ended up upgrading my Grails application to 2.3.5, from 2.2.3 and now the code (above) works perfectly. The 500 error disappeared completely.

AccessTokenAuthorizationCodeRequestC "error":"invalid_request"

At the second call to Client.ProcessUserAuthorization(); after I get the code from the oauth server, I get an exception: Error occurred while sending a direct message or getting the response.
Here is the last part from the log file taken with log4net, the full log is recorded in this gist: https://gist.github.com/tonyeung/5513769
2013-05-03 15:14:41,292 (GMT-5) [10] DEBUG DotNetOpenAuth.Messaging.Channel - Sending AccessTokenAuthorizationCodeRequestC request.
2013-05-03 15:14:41,393 (GMT-5) [10] DEBUG DotNetOpenAuth.Http - HTTP POST http://localhost:38828/OAuth/Token
2013-05-03 15:14:41,450 (GMT-5) [10] ERROR DotNetOpenAuth.Http - http://localhost:38828/OAuth/Token returned 400 BadRequest: Bad Request
2013-05-03 15:14:41,450 (GMT-5) [10] DEBUG DotNetOpenAuth.Http - WebException from http://localhost:38828/OAuth/Token:
{"error":"invalid_request"}
I've uploaded the solution to https://github.com/tonyeung/dotnetopenauth
The entry point is in the about action on the home controller of the Client project.
The solution is in VS2012, the latest nuget dnoa package. Nuget restore is on.
Please note that I'm implementing pieces as I need them in order to understand how the library works. I'm sure that this error is due to a missing implementation somewhere, but I'm not sure what it is?
So it looks like I was missing implementations for IsAuthorizationValid and CreateAccessToken in the Authorization Server. Please check the github repository for the stubs i put in that makes the error go away.
EDIT:
There was also a database validation error that I didn't trap. So basically any error on the server side will cause this message it looks like.
EDIT2:
There was also an issue where if the url of the page contains any non url encoded values it will throw an invalid request. In my case, my login page had a querystring parameter of returnUrl, and I had set it to /Home, which it DID NOT like, had to be: %2FHome

Resources