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

Error #50

Closed
Madji opened this issue Jul 26, 2017 · 5 comments
Closed

Error #50

Madji opened this issue Jul 26, 2017 · 5 comments

Comments

@Madji
Copy link

Madji commented Jul 26, 2017

Acquired SkypeToken
Acquired RegistrationToken
{ net: Unable to subscribe to resources: statusCode: 403 body:
at /laptop/node_modules/skype-http/dist/lib-es2015/lib/login.js:163:35
at Generator.next ()
at fulfilled ( /laptop/node_modules/skype-http/dist/lib-es2015/lib/login.js:4:58)
at process._tickCallback (internal/process/next_tick.js:109:7) name: 'net', data: {} }

@demurgos
Copy link
Member

demurgos commented Jul 26, 2017

Thank you for your report.
I wasn't able to reproduce the issue (so at least it's not a global problem).

Could you tell me more about how the error happened? Are you using authentication with simple credentials (skype login and password)? Is it a temporary error? Is it a new error (were you able to connect to Skype before)?

@Sorunome
Copy link
Contributor

Sorunome commented Jul 26, 2017

Since he is using https://github.com/matrix-hacks/matrix-puppet-skype I can answser a bit: (I am unable to reproduce his issue, too, and told him to make an issue here, since it appears to be within the skype-http library itself)

This is authenticating using username / password,

skypehttp.connect({
    credentials: {
        username: "blah",
        password: "blah"
    },
    verbose: true
})

https://github.com/matrix-hacks/matrix-puppet-skype/blob/master/client.js#L37

@demurgos
Copy link
Member

demurgos commented Jul 26, 2017

Thank you.
I would have expected a 403 error to happen earlier during the login process. When the error happens, the user is already logged (as the logs show it) but is forbidden to register an endpoint for polling. Registration allows to later query new events.

I'd like you to try a few things.

Here is the JS version of subscribeToResources (in dist/lib-est2015/lib/login.js):

function subscribeToResources(ioOptions, registrationToken) {
    return __awaiter(this, void 0, void 0, function* () {
        // TODO(demurgos): typedef
        // tslint:disable-next-line:typedef
        const requestDocument = {
            interestedResources: [
                "/v1/threads/ALL",
                "/v1/users/ME/contacts/ALL",
                "/v1/users/ME/conversations/ALL/messages",
                "/v1/users/ME/conversations/ALL/properties",
            ],
            template: "raw",
            channelType: "httpLongPoll",
        };
        const requestOptions = {
            uri: messagesUri.subscriptions(registrationToken.host),
            cookies: ioOptions.cookies,
            body: JSON.stringify(requestDocument),
            headers: {
                RegistrationToken: registrationToken.raw,
            },
        };
        const res = yield ioOptions.io.post(requestOptions);
        if (res.statusCode !== 201) {
            return Promise.reject(new incident_1.Incident("net", `Unable to subscribe to resources: statusCode: ${res.statusCode} body: ${res.body}`));
        }
        // Example response:
        // {
        //   "statusCode": 201,
        //   "body": "{}",
        //   "headers": {
        //     "cache-control": "no-store, must-revalidate, no-cache",
        //       "pragma": "no-cache",
        //       "content-length": "2",
        //       "content-type": "application/json; charset=utf-8",
        //       "location": "https://db5-client-s.gateway.messenger.live.com/v1/users/ME/endpoints/SELF/subscriptions/0",
        //       "x-content-type-options": "nosniff",
        //       "contextid": "tcid=3434983151221922702,server=DB5SCH101121535",
        //       "date": "Sat, 14 May 2016 16:41:17 GMT",
        //       "connection": "close"
        //   }
        // }
    });
}
  1. Replace interestedResources by an empty array. If you get a 403 even with an empty array, we'll have to investigate further. If the request succeeds, try each resource individually to find the one which causes the error.

  2. Instead of emitting res.body in the error, please log the headers (JSON.stringify(res.headers)).

@Madji
Copy link
Author

Madji commented Jul 27, 2017

function subscribeToResources(ioOptions, registrationToken) {
    return __awaiter(this, void 0, void 0, function* () {
        // TODO(demurgos): typedef
        // tslint:disable-next-line:typedef
        const requestDocument = {
            interestedResources: [
            //    "/v1/threads/ALL",
            //  "/v1/users/ME/contacts/ALL",
            //    "/v1/users/ME/conversations/ALL/messages",
            //    "/v1/users/ME/conversations/ALL/properties",
            ],
            template: "raw",
            channelType: "httpLongPoll",
        };
        const requestOptions = {
            uri: messagesUri.subscriptions(registrationToken.host),
            cookies: ioOptions.cookies,
            body: JSON.stringify(requestDocument),
            headers: {
                RegistrationToken: registrationToken.raw,
            },
        };

I hope I understand correctly. I did so. and got the same error as in the beginning

@demurgos
Copy link
Member

Thank you, that's what I had in mind.
Since you still get a 403 error, it means that the issue was not with a particular resource but the whole registration process. I guess that the official web application works for you? (this library acts as an alternate client mimicking the web application). If it works, I'd need some logs to compare which HTTP requests the web app performs for you. I'll take some time this evening to test it myself and tell you what I need exactly.

@Madji Madji closed this as completed Jul 12, 2018
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

3 participants