moul / node-gitlab

DEPRECATED, see https://github.com/node-gitlab/node-gitlab
https://npmjs.org/package/gitlab
Other
470 stars 140 forks source link

bad token example doesn't work #184

Closed namgk closed 5 years ago

namgk commented 7 years ago

Hi,

On a new install of node-gitlab, the following example failed to produce correct result:

// Connection
var gitlab = require('gitlab')({
  url:   'https://gitlab.com',
  token: 'awef'
});

// Listing projects
gitlab.projects.all(function(a, b, c) {
    console.log(a)
    console.log(b)
    console.log(c)
});

This is the output:

undefined:1
[object Object]
 ^

SyntaxError: Unexpected token o in JSON at position 1
    at Object.parse (native)
    at /Users/nhong/workspace/tmp/node_modules/gitlab/lib/ApiBaseHTTP.js:88:42
    at _Class.wrap_response (/Users/nhong/workspace/tmp/node_modules/slumber/lib/API.js:192:18)
    at _Class.wrap_response (/Users/nhong/workspace/tmp/node_modules/slumber/lib/API.js:4:59)
    at Request._callback (/Users/nhong/workspace/tmp/node_modules/slumber/lib/API.js:215:26)
    at Request.self.callback (/Users/nhong/workspace/tmp/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/nhong/workspace/tmp/node_modules/request/request.js:1171:10)
    at emitOne (events.js:96:13)

Is there any ongoing issue related to this?

Thanks

hauk0101 commented 7 years ago

@namgk I have also encountered the same problem , and then I check the url of my gitlab server , Then the problem is solved. so I suggest you change the url to your gitlab project access to the root address. eg: my project address is "http://192.168.1.10/demo/gitflow-demo" , then the final URL should be "http://192.168.1.10" .

SrMouraSilva commented 6 years ago

Same problem with wrong token.

image

Message body:

Object {message: "401 Unauthorized"}

Gitlab version: GitLab Community Edition 10.3.3 888cf31

SrMouraSilva commented 6 years ago

Appears the problem has been solved: https://github.com/node-gitlab/node-gitlab/commit/ad0ce2fec3d84d5895219e8e20fd546f87e15f61

But the current npm version (1.7.1) not contains the fix

Hello, @moul and @dave-irvine

zsg857981535 commented 6 years ago

I have the same problem !

MrSnoozles commented 6 years ago

same problem

moul commented 6 years ago

Hi, can you try again with latest pushed version (1.8.0) ?

On 30 Mar 2018, at 11:43, MrSnoozles notifications@github.com wrote:

same problem

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/node-gitlab/node-gitlab/issues/184#issuecomment-377490169, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFvTQsblIe62oRdaUPy1edRphnT_WSHks5tjf4xgaJpZM4PKnOg.