Node.js hostname/IP doesnt match certificates altn

2019-06-22 13:01发布

问题:

I'm writing some node code to do a server side login to Facebook. I'm pretty close to having it completely functioning, but I am having troubles requesting the auth_code. I'm thinking it might have something to do with the facebook app setting Site URL but nothing I've tried has worked. I'm using node version 0.8.14.

Here is the code I do my request in:

options =
    host: 'graph.facebook.com'
    port: 443
    path: "/oauth/access_token?" + qs.stringify(
        client_id:     app_id
        redirect_uri:  my_url
        client_secret: app_secret
        code:          vars.code)

https.get(options, (face_res)->
    console.log face_res
)

In the face_res I get a couple of objects like this:

authorizationError: 'Hostname/IP doesn\'t match certificate\'s altnames'

Any help is greatly appreciated

回答1:

Ok funny thing is the error I was getting was completely irrelevant. As soon as I added a request.on("data", function(data){}) event listener I was able to see that I was receiving the auth_token as expected.