octokit / octokit.js

The all-batteries-included GitHub SDK for Browsers, Node.js, and Deno.
MIT License
7.03k stars 1.03k forks source link

issue when retrieving pending organisations #417

Closed billbuilder closed 8 years ago

billbuilder commented 8 years ago
let github = new GitHubApi({
        debug: true,
        protocol: 'https',
        host: 'api.github.com', // should be api.github.com for GitHub
        pathPrefix: '/api/v3', // for some GHEs; none for GitHub
        headers: {
            'user-agent': 'Skyfeld-App' // GitHub is happy with a unique user agent
        },
        followRedirects: false, // default: true; there's currently an issue with non-get redirects, so allow ability to disable follow-redirects
        timeout: 5000
    })
    github.authenticate({
        type: 'basic',
        username: '...',
        password: '...'
    })
    github.orgs.getOrganizationMemberships({ state: 'pending' }, function (err, res) {
        console.log( '.........', err, res )
    })

Username and password are good, but I receive this:

{ [Error: {"message":"Not Found","documentation_url":"https://developer.github.com/v3"}]
[error]   message: '{"message":"Not Found","documentation_url":"https://developer.github.com/v3"}',
[error]   code: 404,
[error]   status: 'Not Found',
[error]   headers: 
[error]    { server: 'GitHub.com',
[error]      date: 'Wed, 14 Sep 2016 10:02:30 GMT',
[error]      'content-type': 'application/json; charset=utf-8',
[error]      'content-length': '77',
[error]      connection: 'close',
[error]      status: '404 Not Found',
[error]      'x-ratelimit-limit': '5000',
[error]      'x-ratelimit-remaining': '4979',
[error]      'x-ratelimit-reset': '1473850241',
[error]      'x-github-media-type': 'github.v3; format=json',
[error]      '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',
[error]      'access-control-allow-origin': '*',
[error]      'content-security-policy': 'default-src \'none\'',
[error]      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
[error]      'x-content-type-options': 'nosniff',
[error]      'x-frame-options': 'deny',
[error]      'x-xss-protection': '1; mode=block',
[error]      'x-github-request-id': '5CF99554:3654:C9D2715:57D92036' } } { state: 'pending' }

any idea would be much appreciated!

kaizensoze commented 8 years ago

There's users.getOrganizationMemberships and orgs.getOrganizationMemberships. You probably want the users one which is for an authenticated user. The orgs endpoint requires a :user param and doesn't take a state param.

billbuilder commented 8 years ago

Oh I get it, thanks!