[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [jfw] Getting Github Milestones via Basic Authentcation



Hi Andrew,

Yes I've just submitted a PR to the gihub-api package that sets the relevant HTTP client headers for basic auth if the api.username and api.password are set.

https://github.com/joomla-framework/github-api/pull/4

I'm not sure if this is the best approach through?

Eric.

On 25/03/2014, at 10:17 AM, Andrew Eddie <mamboblue AT gmail.com> wrote:

Ok, so it looks like `GithubObject`'s `fetchUrl` method is just
including the user and password in the URL, not in the header. It
feels like we need an option of use header based basic auth rather
than auth in the URL.

Regards,
Andrew Eddie


On 25 March 2014 09:03, Eric Fernance <> wrote:
Okay, I managed to get to the bottom of this after comparing the headers sent from curl:

To access private repos using the Joomla\Github\Github this additional line is needed:

$options->set('headers.Authorization','Basic '.base64_encode('mygithubusername'.':'.'mygithubpassword'));


So I ended up doing this:

//create the registry object containing the github options
$options = new Registry;
$options->set('api.username','githubusername');
$options->set('api.password','githubpassword');
$options->set('api.url','https://api.github.com');
$options->set('headers.Accept', 'application/vnd.github.html+json');
$options->set('headers.Authorization','Basic '.base64_encode('githubusername'.':'.'githubpassword'));


//create the github object.
$github = new Github($options);

$milestonedetails = $github->issues->milestones->get('githubusername','reponame',repoid);

This then worked for me.

So after getting it working that way I then removed the setting of the headers in the registry and modified the Joomla\Github\Github constructor to add the following at the end of the constructor:

               if ($this->getOption('api.password') && $this->getOption('api.username'))
               {
                       $this->client->setOption('headers.Authorization','Basic '.base64_encode($this->getOption('api.username').':'.$this->getOption('api.password')));
               }

I will create a pull request for this small fix unless it's likely to break OAuth or Server authentication?

Not sure as I haven't dabbled with that??

Eric.

On 24/03/2014, at 6:06 PM, Eric Fernance <beanie AT purplebeanie.com> wrote:

Thanks Andrew,

I'll give it a rest over night and see how it works out tomorrow!

You're right about not authenticating properly.... It was having a look at the exception messages and it was telling me I wasn't authenticated.

I'll see how it goes tomorrow!

Thanks again!

Eric.

On 24/03/2014, at 6:02 PM, Andrew Eddie <mamboblue AT gmail.com> wrote:

Hi Eric

From the response, the rate limiting is telling me you aren't
authenticating properly (X-RateLimit-Limit is 60 instead of 6000). I
can't see where you are going wrong though because it looks like the
same way I use the API:

https://github.com/eddieajau/tagaliser/blob/master/src/Tagaliser/Providers/GithubServiceProvider.php#L42

That said, I've had trouble with hitting the Tags service today so it
might not be your end that's the problem.

Regards,
Andrew Eddie
http://learn.theartofjoomla.com - free tutorials and videos on Joomla
development


On 24 March 2014 17:42, Eric Fernance <> wrote:
From the github docs under authentication it says:

There are three ways to authenticate through GitHub API v3. Requests that
require authentication will return 404 Not Found, instead of 403 Forbidden,
in some places. This is to prevent the accidental leakage of private
repositories to unauthorized users.


That's why I was curious how I could pass the AUTHENTICATION_BASIC to the
Joomla\Github\Http.  I thought about creating a Joomla\Github\Http object
then passing it as part of creating the Github object but I can't figure out
what the option key would be.

Eric.




On 24/03/2014, at 5:38 PM, Eric Fernance <> wrote:

A Joomla\Http\Response object with code 404.

Which apparently is pretty standard for github on private repos without
authentication (at least according to the github site)

full extract here:

Joomla\Http\Response Object ( [code] => 404 [headers] => Array ( [Server] =>
GitHub.com [Date] => Mon, 24 Mar 2014 07:33:48 GMT [Content-Type] =>
application/json; charset=utf-8 [Connection] => close [Status] => 404 Not
Found [X-RateLimit-Limit] => 60 [X-RateLimit-Remaining] => 3
[X-RateLimit-Reset] => 1395648458 [X-GitHub-Media-Type] => github.beta;
format=json [X-Content-Type-Options] => nosniff [Content-Length] => 76
[Access-Control-Allow-Credentials] => true [Access-Control-Expose-Headers]
=> ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining,
X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
[Access-Control-Allow-Origin] => * [X-GitHub-Request-Id] =>
DF1B12EC:64AE:5850672:532FDFDB ) [body] => {"message":"Not
Found","documentation_url":"http://developer.github.com/v3"} ) 1

Eric
On 24/03/2014, at 5:22 PM, Andrew Eddie <mamboblue AT gmail.com> wrote:

Interesting problem. I've never tried private repo's before.

https://github.com/joomla-framework/github-api/blob/master/src/Package/Issues/Milestones.php#L48

What do you get on your server if you do a var_dump on $response?

Regards,
Andrew Eddie


On 24 March 2014 15:54, Eric Fernance <beanie AT purplebeanie.com> wrote:

Hi Folks,

I've spent a couple of hours hunting around trying to work out how to do
this but I'm stumped.

I need to retrieve milestones for a couple of different github repos (all
owned by me).  I need to use basic authentication as I will only have
username and password.

So far I have gotten to this:

//create the registry object containing the github options
$options = new Registry;
$options->set('api.username','githubusername');
$options->set('api.password','githubpassword');
$options->set('api.url','https://api.github.com');


//create the github object.
$github = new Github($options);

$milestonedetails =
$github->issues->milestones->get('githubusername','reponame',milestoneid);

Works fine on public repos and from my test environment (but I have SSH
keys) but won't get milestones for my private repos when I install on host's
server.

I can see the constant: AUTHENTICATION_BASIC in the source code but I'm
unsure where to set it and what the option name should be.  I'm guessing I
can pass it as part of the Registry object but I can't work out what name it
should be.

Can anyone give me some pointers?

Eric.


--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with
Joomla!
---
You received this message because you are subscribed to the Google Groups
"Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.


--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with
Joomla!
---
You received this message because you are subscribed to the Google Groups
"Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.



--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with
Joomla!
---
You received this message because you are subscribed to the Google Groups
"Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.


--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with
Joomla!
---
You received this message because you are subscribed to the Google Groups
"Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.