Guzzle HTTP client auth fail

93 views
Skip to first unread message

Layla Wang

unread,
Feb 25, 2015, 12:36:07 PM2/25/15
to guz...@googlegroups.com

I'm working on a project that need to call a API to get json response, but the Guzzle client auth is not working. It always redirect to the login page. "nasa" is the database. Here's my code:

<?php
require_once '../composer/vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client([
    'base_url' => ['http://fedview.bfountain.com/{datasource}/', ['datasource' => 'nasa']]]);
$response = $client->get('service/sbapp/goalByAgency', ['auth' =>  ['username', 'password']]);
echo $response->getBody();
?>

I tried:

$response = $client->get('login.do?uname=username&passcode=password');

It can log in successfully.

Can anyone help me on this? (I'm using Guzzle 5) THX!

Douglas Gough

unread,
Apr 8, 2015, 12:57:33 PM4/8/15
to guz...@googlegroups.com
Your description is a bit confusing. You say "Guzzle client auth is not working", but later you say "It can log in successfully". Please clarify.

Thanks
Reply all
Reply to author
Forward
0 new messages