Code Monkey home page Code Monkey logo

Comments (7)

csarrazi avatar csarrazi commented on June 14, 2024

Yes, it should. If you are using Http Basic, the configuration should be like this.

For the Github API, the configuration should be something like:

csa_guzzle:
    clients:
        github_api:
            config:
                base_url: https://api.github.com
                defaults:
                    headers:
                        Authorization: token mygithubtoken1234567890
                        Accept: application/vnd.github.v3+json

For http-basic, you simply need to transpose your guzzle config array in the yaml configuration.

from csaguzzlebundle.

csarrazi avatar csarrazi commented on June 14, 2024

Basically, the config key is used to inject your Guzzle client's config. This config is exactly what is mentioned in Guzzle's documentation, as the client's constructor argument.

from csaguzzlebundle.

thim81 avatar thim81 commented on June 14, 2024

Hi Csarrazi,

Thanks for the quick and clear explanation.

Guzzle mentions the usage like:

$client->request('GET', '/get', ['auth' => ['username', 'password']]);

So looking at your example and my example, this could work:

csa_guzzle:
    clients:
        my_api:
            config:
                base_url: https://api.service.com
                defaults:
                    headers:
                        Authorization: username password
                        Accept: application/json

from csaguzzlebundle.

csarrazi avatar csarrazi commented on June 14, 2024

Nope. It would be something like

csa_guzzle:
    clients:
        my_api:
            config:
                base_uri: https://api.service.com
                auth: [login, mypassword]
                headers:
                    Accept: application/json

from csaguzzlebundle.

csarrazi avatar csarrazi commented on June 14, 2024

Which reminds me that I need to update the documentation for the master branch.

from csaguzzlebundle.

thim81 avatar thim81 commented on June 14, 2024

Hi Csarrazi,

In the documentation it was mentioned "base_url" instead of "base_uri" and the auth: [login, mypassword] is also handy as reference.

Thanks again for you help and quick support.

I'm gonna close this since it's solved

from csaguzzlebundle.

csarrazi avatar csarrazi commented on June 14, 2024

No problem. I'm currently updating the documentation (both the documentation for the master branch and the UPGRADE.md documentation, for people migrating from 1.x to 2.x), so there are less issues about this.

from csaguzzlebundle.

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.