Google Sheet API Update tokens? - java

For god's sake I'm out of my mind right now.
I can't get to seemingly an extremely easy point, I've travelled through hundreds of web pages, but couldn't succeed in finding an answer.
I've been using Google Sheet API (Java lang), and when I started it was all fine and working. And is still working, but the problem is - I need to change my account. Because of reasons, no other way
I'm copying all the new credentials, doing step-by-step what the Quickstart says, but yet every time I try to get access to the spreadsheet I get this:
Exception in thread "main" com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized
at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)
at com.google.api.client.auth.oauth2.Credential.executeRefreshToken(Credential.java:576)
at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:493)
at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:868)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
I've tried deleting tokens folder. Even tried to create a totally new project. Nothing works.
Where does the problem hide? In browsers? What browser? I'm using Safari (which is default), but I've got Chrome on my Mac too.
Please help, I'm desperate, it's deadline today

Related

Docusign OAuth getAccessToken failing for Java app

I have a Java application which has been Docusigning away nicely until it broke sometime last week (might have been anytime in the last couple of weeks) .
Nothing has changed on my side, so I suspect some change on the Docusign front.
The symptoms are very puzzling and are as follows :
Sign-in with OAuth works fine up to the stage when it attempts to get the access token, at which point it hangs until it times out. The initial phases (log in, call callback with generated oauth code which then calls the getAccesCode component ) work fine, and here's the kicker - if I plug the exact values from the hanging getAccessToken call into curl and execute it from the same server, it works fine.
Here are the details of the hanging call :
getAccessToken request location='https://account-d.docusign.com/oauth/token'
getAccessToken request body=grant_type=authorization_code&code=<many characters>'
getAccessToken Request header : Authorization:Basic Y2E1ZWM3N2UtMGQ4 + MORE
So it is definitely something to do with the Java libraries, however it is not possible to get a debug trace of the OAuth part on the Docusing server (although I know you can trace the actual API calls by enabling the Docusign logs it does not appear to trace the oauth steps )
What is puzzling is that it was working fine for months. And now works fine with curl, but just hangs in Java. I suspected SSL , but if that were the case why do the initial steps work ?
This is the Java stacktrace , interestingly does not always get dumped (but the hang always happens)
java.net.SocketException: Connection timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
at sun.security.ssl.InputRecord.read(InputRecord.java:480)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:658)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1323)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
at org.apache.oltu.oauth2.client.URLConnectionClient.execute(URLConnectionClient.java:98)
As mentioned , running curl against https://account-d.docusign.com/oauth/token with parameters grant_type=authorization_code and the generated code=blah with the appropriate auth header works fine, returning the correct json response.
Any ideas anyone ? How can I trace the Docusign side to find out why it is hanging ? What has changed of late ? New SSL certs ? I'm stumped.
Per Amit and DS Support, DocuSign has ended support for TLS1.0 in Demo from May 29th, 2018 and will soon end the support in PROD as well. Please test the connection on your end if you are using TLS1.0, if yes then you need to upgrade it to TLS1.1+ to again start using DS APIs. I am assuming if you have not done any code changes then this is the issue which you are seeing in your application.

HTTP Status 404 - /ssssnpm//promotional.jsp error

Whenever I connect to my broadband internet, it shows this message -
"HTTP Status 404 - /ssssnpm//promotional.jsp"
Apache Tomcat/7.0.57
I searched a lot about this issue but couldn't find it. Everyone is talking about Tomcat or Apache servers. I don't use any IDE. I am not a programmer, so I didn't write any codes. I am just not able to open any web page. Whenever I enter any URL, it redirects me to another URL, which seems to be an IP address. And, that page shows this error message (wrote above).
I suspect that it could be because of an antivirus I installed a couple of days ago on my laptop and my phone as well. But, it's showing the same error to my brother's phone on which this antivirus isn't installed.
other internet connections are working fine on my laptop - like my mobile internet.
Please help in resolving this issue.
The issue is resolved now. It was some server error as it was unable to load a file something "promotional.jsp"
The message Apache Tomcat/7.0.75 was a bit confusing to me. So, posted a question here.
this is not internet connection problem this is background code problem apache could not found specific file which you want to access
thanks

Google Drive revokes my token

I am new to google drive and started with the tutorial quickstart.
After numerous attampts I run the program successfully.
However I had permission and authorisation problems when I was trying to delete files.
Drive service = getDriveService();
service.files().delete("FileId").execute();
So I decide to change the URL in the client_secret.json,
From: "auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs"
To: "auth_provider_x509_cert_url":"https://www.googleapis.com/auth/drive"
in the hope that I would now get the permission to delete files. However after executing the program again I didn't get the authorization tab of the internet browser like before.
As an example of the mentioned tab, here an image from google playground:
That's the reason why I delted the connection from my app to google drive website:
In addition i recreated also the client_secret.json file. However when I now execute the program I get only this error, independent what I am doing.
Exception in thread "main" com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request
{
"error" : "invalid_grant",
"error_description" : "Token has been revoked."
}
at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)
at com.google.api.client.auth.oauth2.Credential.executeRefreshToken(Credential.java:570)
at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489)
at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at main.java.DriveQuickstart.main(DriveQuickstart.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
So the two questions are what should i do to get the tutorial running again and how to set the permissions so that i can delete files?
Now I find out the problem:
I had to delete the directory "user.home/.credentials/drive-api-quickstart".
After that I can give the program the authorisation, which it needs.
Hope that someone will help this post ;)
I had a slightly different case. After getting the example in the Quick Start Guide to work a few months ago, I got the following error today when rerunning it.
Exception in thread "main" com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request
{
"error" : "invalid_grant",
"error_description" : "Bad Request"
}
Since the tokens were stored in TOKENS_DIRECTORY_PATH ("tokens"), the token stored there probably became invalid. Deleting directory tokens allowed me to once again get the browser page to select a gmail account to proceed with. Everything worked from there.

Google App Engine instance crashing with ErrorCode 121

My GAE app suddenly stopped working last friday. I tried several times to start an instance in background, (both using cron and manually) but after a minute since the instance starts I get this error:
/cron/spreadsheet 500 4660ms 0kb instance=0 AppEngine-Google;
(+http://code.google.com/appengine)
0.1.0.1 - - [17/Feb/2013:12:40:05 -0800] "GET /cron/spreadsheet HTTP/1.1" 500 0 -
"AppEngine-Google; (+http://code.google.com/appengine)"
"backend.myclimagest.appspot.com" ms=4661 cpu_ms=692 queue_name=__cron
task_name=5ed789ec52683cb170ed3c2cc4ec48c9 pending_ms=3651 exit_code=121
instance=0
W 2013-02-17 12:40:05.268
A problem was encountered with the process that handled this request,
causing it to exit. This is likely to cause a new process to be used
for the next request to your application. (Error code 121)
I don't know what to do since this error code is undocumented. I also tried to redeploy but no luck. Are you experiencing the same problem and have you maybe found a solution?
I don't think it matters but the app is developed in Java using Eclipse.
The app is in production so I really need to solve this issue as quickly as I can.
Thank you
It seems your App Engine scheduler got problem. Try this, Removing the automatic settings from Performance settings which seeems to help. Google Groups
Check this Official Google page too Managing Your App's Resource Usage

Firefox has detected that the server is redirecting the request for this address in a way that will never complete

I'm following Scott Davis' tutorials on developing grails apps, but whenever i try to run my app (or indeed his source code) i get "Firefox has detected that the server is redirecting the request for this address in a way that will never complete." Safari gives a similar error message as does Opera.
As i've tested the original authors source code which gives the same error i'm fairly confident it's nothing to do with the code.
Is this a problem with the web server on my machine? I use Mac OS Snow Leopard so i'm assuming it's apache that's generating this error.
Edit: Seems Grails as standard uses Jetty, so probably not Apache that is causing the problem. However also tested the app on Glassfish and i get the same error.
Anyone know what i can do to fix this?
Cheers
It depends on the code and Apache configuration you are using. I assume that the web server sends cyclic HTTP redirections, eg. from /root/ to /root (without the slash) and vice versa. This causes a redirection infinite loop.
Check your configuration on conditions that cause a HTTP redirect. For example, Apache automatically adds slashes to directory URLs in standard configuration (like the /root/ example above). I don't know Grails, so I cannot give you a hint on how URLs are processed within the app.
You can also use manual HTTP requests for debugging to see whats going on behind the scenes, using telnet on a terminal:
$ telnet localhost 80
GET / HTTP/1.0
I guess the response will be something like that:
HTTP/1.0 302 Found
Location: XXX
...
Now do a second request on the URL passed in the Location header and so on.
I was getting the same error a little while ago, heres how I fixed:
Try the same page on a different internet setup (it could be your ISP)
Open up Safari, Firefox or whatever your using and empty the cache and delete ALL your cookies
Reboot your computer and try again
It may work now, but if it doesn't:
open up Firefox and type 'about:config' (without the quotes) into the URL bar
You will get some little warning, just press OK
Type 'redirect' into the Filter box
You should see a listing for 'network.http.redirection-limit'
Double click the listing and type a large number (anything above 50 and lower than 200)
Press OK, quit and re-open FireFox
Basically all that does is make FireFox's tolerance for redirect loops higher which should fix your problem - but usually, just borrowing someone else's internet connection fixes it
Hope that all helps =)
Just carefully check your URLMappings configuration:
YOUR_APP/grails-app/conf/UrlMappings.groovy
Common case:
You configured request to be handled like this:
"/anything" (controller:"someController")
So without action, request will be handled by default one, "index". "index" action usually redirects to "list", and "list", in some cases redirect back to "index"
There is your loop.
Good luck

Categories

Resources