SamsonIT / YouTrack

General classes to communicate with the YouTrack API
0 stars 6 forks source link

login function non working #1

Closed yannmadeleine closed 11 years ago

yannmadeleine commented 11 years ago

When I call the login function I have a 400 as a response, it seems linked to buzz, if I modify the class to use guzzle without modifying the options then everything works.

Burgov commented 11 years ago

Hi Yan, can you give us the exact response you're getting from YouTrack? We can't reproduce the problem here...

yannmadeleine commented 11 years ago

Hello, the messages that I have

Fatal error: Uncaught exception 'YouTrack\Exception\APIException' with message 'The server responded with a 400 status code in method YouTrack\YouTrackCommunicator::login: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>Bad Request' in /srv/vhosts/users/ymadeleine/opinfo/www/vendor/samson/youtrack/src/YouTrack/YouTrackCommunicator.php on line 64

YouTrack\Exception\APIException: The server responded with a 400 status code in method YouTrack\YouTrackCommunicator::login: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>Bad Request in /srv/vhosts/users/ymadeleine/opinfo/www/vendor/samson/youtrack/src/YouTrack/YouTrackCommunicator.php on line 64

and here is the list of my installed libraries

doctrine/common 2.2.3 Common Library for Doctrine projects doctrine/dbal 2.2.x-dev 7331fdb Database Abstraction Layer knplabs/console-service-provider dev-master 2c01c4d console service provider for Silex knplabs/migration-service-provider dev-master a7bc01b Doctrine migration service provider for Silex knplabs/repository-service-provider dev-master 62920db Doctrine repository service provider for Silex kriswallsmith/buzz v0.7 Lightweight HTTP client monolog/monolog 1.1.0 Logging for PHP 5.3 pimple/pimple dev-master v1.0.2 Pimple is a simple Dependency Injection Container for PHP 5.3 psr/log 1.0.0 Common interface for logging libraries samson/youtrack dev-master e9db131 Service to communicate with the YouTrack API silex/silex 1.0.x-dev a6dde11 The PHP micro-framework based on the Symfony2 Components symfony/config 2.1.x-dev v2.1.11 Symfony Config Component symfony/console 2.1.x-dev a5e96b2 Symfony Console Component symfony/debug dev-master bcf326c Symfony Debug Component symfony/event-dispatcher 2.1.x-dev v2.1.11 Symfony EventDispatcher Component symfony/filesystem 2.1.x-dev v2.1.11 Symfony Filesystem Component symfony/finder 2.1.x-dev v2.1.11 Symfony Finder Component symfony/form 2.1.x-dev v2.1.11 Symfony Form Component symfony/http-foundation 2.3.x-dev v2.3.1 Symfony HttpFoundation Component symfony/http-kernel 2.3.x-dev 99b9acb Symfony HttpKernel Component symfony/locale 2.1.x-dev v2.1.11 Symfony Locale Component symfony/options-resolver 2.1.x-dev v2.1.11 Symfony OptionsResolver Component symfony/process 2.1.x-dev v2.1.11 Symfony Process Component symfony/routing 2.3.x-dev v2.3.0 Symfony Routing Component symfony/translation 2.1.x-dev v2.1.11 Symfony Translation Component symfony/twig-bridge 2.1.x-dev v2.1.11 Symfony Twig Bridge symfony/validator 2.1.x-dev v2.1.11 Symfony Validator Component twig/twig dev-master 6f75320 Twig, the flexible, fast, and secure template language for PHP

Regards

Burgov commented 11 years ago

That's weird... It works just fine here. Do you have curl? What happens when you run the following?

curl !!!your YouTrack URL!!!/rest/user/login -H"Accept: application/json" -H"Content-type: application/x-www-form-urlencoded" -d"login=test&password=test"

yannmadeleine commented 11 years ago

Hello, when trying the curl I have the response

{"value":"Incorrect login or password."}

which is correct because I didn't put the right credentials, but as I said if I modify the library to use guzzle it works, so it doesn't seems to be linked to my network.

Bests

Burgov commented 11 years ago

I see in your list of vendors that you are not using the YouTrackBundle. Can you tell me how you instantiate the Browser object? Are you using the Curl client or the FileGetContents one?

yannmadeleine commented 11 years ago

Yep I don't use symfony so I don't use the bundle neither.

Here a stripdown version of my boostrap

<?php

require_once __DIR__.'/../vendor/autoload.php';

use Concerto\Application;

use Silex\Provider\TwigServiceProvider;
use Silex\Provider\UrlGeneratorServiceProvider;
use Silex\Provider\DoctrineServiceProvider;
use Silex\Provider\MonologServiceProvider;
use Silex\Provider\FormServiceProvider;
use Silex\Provider\TranslationServiceProvider;
use Silex\Provider\SessionServiceProvider;
use Silex\Provider\ValidatorServiceProvider;
use Silex\Provider\ServiceControllerServiceProvider;

use Knp\Provider\ConsoleServiceProvider;
use Knp\Provider\MigrationServiceProvider;
use Knp\Provider\RepositoryServiceProvider;

use YouTrack\YouTrackCommunicator;
use Buzz\Browser;

use Poivre\Controller\IssueController;

$app = new Application();

$app->register(new FormServiceProvider());
$app->register(new TranslationServiceProvider());
$app->register(new SessionServiceProvider());
$app->register(new ValidatorServiceProvider());

$app->register(new ServiceControllerServiceProvider());

$app['youtrack'] = $app->share(function() use ($app) {
    return new YouTrackCommunicator( new Browser(), [
            'username'=>'USER',
            'password'=>'PASSWORD',
            'uri'=>'http://xxx.myjetbrains.com/youtrack'
            ]
        );
});

$app['issues.controller'] = $app->share(function() use ($app) {
    return new IssueController($app['youtrack']);
});

As you can side I don't specify which client to use so I guess is the FileGetContents one

yannmadeleine commented 11 years ago

I just tried it with the Curl client instead of the FileGetContents and it works, little did I know about the 2 different clients. Thanks a lot.