GithubHelp home page GithubHelp logo

Comments (6)

erickoledadevrel avatar erickoledadevrel commented on August 11, 2024

I'm not sure why you are running into a timeout, but you can increase the timeout length using the code listed here:

https://developers.google.com/api-client-library/java/google-api-java-client/errors#timeouts

from java-samples.

mohammadashrafvora avatar mohammadashrafvora commented on August 11, 2024

Link is showing to add timeout in HttpRequestInitializer.

image

Google API for mail uses Credential class and implements HttpRequestInitializer. and Lines that I marked as yellow are not able to execute because I am getting Credential as null.

Here, this time out will come in picture only after authorise() method completes. But in my case, I am getting time out on line "TokenResponse response = flow.newTokenRequest(code).setRedirectUri(redirectUri).execute();". This line redirects me to url as below: "http://localhost:25745/Callback?code=4/AABrLErTmOxzKEqqD31iiMftE93i3k06oJ4sAI34uS7jI7U-VAdofx0hV8ZoyzHEJyjFEx6x1VYASMNe779Dpa0#"

And this is where exact problem lies and I am not able to execute "return flow.createAndStoreCredential(response, userId);" line. I think If I get TokenResponse, Token will be stored as a file and it should work.

from java-samples.

erickoledadevrel avatar erickoledadevrel commented on August 11, 2024

I see, the timeout there is for the service itself, but this is happening earlier with the OAuth flow. Some more searching indicates this is a proxy issue. Please try the recommended solution here:

https://stackoverflow.com/a/39347143

from java-samples.

mohammadashrafvora avatar mohammadashrafvora commented on August 11, 2024

I consulted network team for proxy related details but in our environment proxy is not configured.
I have debugged further into timeout issue and finding are as below:
API is trying to execute redirect url with code and get authentication Token.
When I debugged I got redirect urls as :
http://localhost:37946/Callback with code appended as specified above
I stopped before executing redirect request in debugging and got a snapshot of TCP View as below:
image
As one can see, there is port opened but Client API is not able to connect to this port and gives time out error.

from java-samples.

erickoledadevrel avatar erickoledadevrel commented on August 11, 2024

Looking at the stack trace you posted earlier, the timeout is happening when the code tries to make a request to Google's OAuth2 https://www.googleapis.com/oauth2/v4/token endpoint, not with the callback URL. See if you can make a request to that URL in your Java environment using other means.

from java-samples.

erickoledadevrel avatar erickoledadevrel commented on August 11, 2024

Closing due to inactivity.

from java-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.