Code Monkey home page Code Monkey logo

Comments (8)

tylerstillwater avatar tylerstillwater commented on July 18, 2024

The pattern for this kind of thing thus far has been callback functions that the user can set to provide customized functionality.

I would recommend having an GetClient() function that returns the http.Client to use for fetching the URL. By default, this should return a new client, but it could be overridden by calling code (see GetProviderName) to return the urlfetch.Client for use on App Engine.

This also has the added benefit of not strongly binding goth to any app engine code or logic.

@markbates thoughts?

from goth.

RubenN avatar RubenN commented on July 18, 2024

Sounds like a valid solution if it is in line with Mark's thoughts.

from goth.

markbates avatar markbates commented on July 18, 2024

I don't use GAE, so I'm not sure of the exact nature of the problem, so I'll leave this to Tyler's discretion, as he seems to have a handle on this.

from goth.

tylerstillwater avatar tylerstillwater commented on July 18, 2024

Sounds good. The approach I posted above should work just fine. @RubenN do you want to go ahead and implement this, then submit a PR?

from goth.

RubenN avatar RubenN commented on July 18, 2024

Ok

from goth.

RubenN avatar RubenN commented on July 18, 2024

It turned out to be even simpler and doesn't require code changes.
The key is to change the default http client and transport like this:

http.DefaultClient = &http.Client{ Transport: &urlfetch.Transport{Context: c}, } http.DefaultTransport = &urlfetch.Transport{Context: c}

from goth.

oyvindsk avatar oyvindsk commented on July 18, 2024

For the record, this does not work anymore with newer versions of oauth2. It looks like it should be unnecessary now, but I can't get it to work at all with oauth2 released after this commit:
golang/oauth2@96e89be

Works if you revert back to before that commit and use @RubenN 's sollution

from goth.

markbates avatar markbates commented on July 18, 2024

As before, I don't use GAE, so I can't produce. However, @oyvindsk if you can reproduce and know a fix please submit a PR so we can close this. Thanks.

from goth.

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.