Hoping to play around and contribute this back when I make some headway. Just wanted to post so that I don't forget to contribute back :)


patcon’s picture

Not sure whether more presets are useful or best kept in another module, but here it is, just in case. Only been testing locally, so haven't done the final bit of testing to prove that it completely works :)


patcon’s picture

Still toying around with this. Was getting an issue on my local VM, so just recently got around to trying on a Rackspace server, thinking oauth didn't work locally. Found the same error happening, and so dug in to discover that local development shouldn't make a difference.

I'll work on packaging up my setup to work with the Ariadne vagrant development VM, so that anyone interested in GitHub testing can reproduce the error with very little effort :)

    ... (Array, 4 elements)
        token (Boolean) TRUE
        params (Array, 5 elements)
            grant_type (String, 18 characters ) authorization_code
            code (String, 20 characters ) 8949f10c2bf44da0d1a9
            client_id (String, 20 characters ) 07b85c87b6228e517e74
            client_secret (String, 40 characters ) MY SECRET
            redirect_uri (String, 40 characters ) http://IP_ADDRESS/oauth/authorized2/1
        realm (NULL)
        get (Boolean) FALSE
    Krumo version 0.2.1a
    | http://krumo.sourceforge.net
    [Click to expand. Double-click to show path.] Called from /root/docroot/profiles/drupalgithub/modules/contrib/oauthconnector/modules/oauth2/lib/DrupalOAuth2Client.inc, line 105

Error message
Exception: Failed to fetch data from url "https://github.com/login/oauth/access_token" (HTTP response code 406 Not Acceptable): in DrupalOAuth2Client->get() (line 125 of /root/docroot/profiles/drupalgithub/modules/contrib/oauthconnector/modules/oauth2/lib/DrupalOAuth2Client.inc).

That krumo output above is for dpm($options) from right before curl_init() in get()

patcon’s picture

Oh, and here's an install profile sans the client and secret keys:

Jon Pugh’s picture

I was getting the same thing, thankfully I found your github module and realized its not just my problem...

Trying to solve this. After hours of staring at the request it still looks right to me...

Found this description of HTTP 406 code that might help:

406 Not Acceptable: Returned when parameters passed are correct in theory and individually, but when combined can not be satisfied because the combination makes no sense (e.g. cart_id from one user is used with a user_id from another user). If possible, an error message will be returned to provide further details.


Jon Pugh’s picture

Well, I'll be. A fresh night's sleep does wonders.

the current code in DrupalOAuth2Client.inc uses x-www-form-urlencoded

    $headers = array(
      'Accept: application/x-www-form-urlencoded',

I changed it to 'application/json' and voila! It works!

    $headers = array(
      'Accept: application/json',

Now... I guess we need to patch oauthconnector?

Anonymous’s picture

Thank you for that fix very much :)

jsacksick’s picture

Status: Active » Needs review
1.82 KB

Here's the patch that adds the preset, I haven't touched the $headers array.

patcon’s picture

Ditto what @alex_bytsiuk said :) Thanks @jonpugh!

Anonymous’s picture

@jsacksick but your patch don't solve the problem. Did you try to fix the bug or just add GitHub as preset provider?

patcon’s picture


Appreciate the patchifying @jsacksick, but I wasn't looking to get a github preset into core, since that's why the module is extensible

patcon’s picture

Meh. I know it's not the right approach to get accepted into the module, but here's the patch for @jonpugh's hack :)

dxx’s picture

Issue summary: View changes

Patch "resolve" issue for me. Using "application/json" does not break others providers (tested with Google, Twitter, Facebook, Linkedin and GitHub).

For get the email field from GitHub profil you need to use "user" in scope and "https://api.github.com/user/emails" at ressource but it's not possible to map a array field, one solution? It's possible with QueryPath?

Found! (no QueryPath required) simply use: "0.email".