Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github API call fails after successful login #26

Open
VladyslavKurmaz opened this issue Mar 26, 2018 · 0 comments
Open

Github API call fails after successful login #26

VladyslavKurmaz opened this issue Mar 26, 2018 · 0 comments

Comments

@VladyslavKurmaz
Copy link

VladyslavKurmaz commented Mar 26, 2018

Issue

Github API rejects simple API call GET /users after successful login
https://developer.github.com/v3/users/#get-a-single-user
API responce

{ error: null,
body: 'Request forbidden by administrative rules. Please make sure your request has a User-Agent header (http://developer.github.com/v3/#user-agent-required). Check https://developer.github.com for other possible causes.\n',
 status: 403,
 message: 'Forbidden' }

How to reproduce

  • Login using github
  • Call API endpoint /user
app.get('/api', function (req, res){
    oauth.auth('github', req.session, {
      credentials: req.session.credentials
    }).then(function (request_object) {
            return request_object.get('/user', {
            });
        })
        .then(function (r) {
           res.status(200).send('<pre>' + JSON.stringify(r) + '</pre>');
        })
        .fail(function (e) {
            res.status(400).send('An error occured while posting the message');
        });
});

package.json

  "dependencies": {
    "cors": "^2.8.4",
    "express": "^4.16.3",
    "express-session": "^1.15.6",
    "npm": "^5.8.0",
    "oauthio": "^0.3.5",
    "session-file-store": "^1.2.0",
    "to": "^0.2.9",
    "update": "^0.7.4"
  },
  "devDependencies": {
    "nodemon": "^1.17.2"
  }

request_object

{ access_token: 'xxxxxxxxxxxxxxxxx',
 token_type: 'bearer',
 request: 
 { url: 'https://api.github.com',
    cors: true,
       headers: { Authorization: 'Bearer {{token}}' } },
     state: 'xxxxxxxxxxxxxxxxx',
     provider: 'github',
     refreshed: false,
     get: [Function],
     post: [Function],
     patch: [Function],
    put: [Function],
    del: [Function],
    me: [Function],
     getCredentials: [Function],
    wasRefreshed: [Function] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant