mckelvey / instagram-node-lib

The Instagram Node Lib is a helper library for node that makes communicating with the Instagram API easy.
http://david.mckelveycreative.com/
Other
303 stars 49 forks source link

User info requires access_token #8

Closed scttnlsn closed 11 years ago

scttnlsn commented 11 years ago

I am getting an "Error: APINotAllowedError: you cannot view this resource" when requesting user info. When I monkey patch the info function to include the access_token things seem to work fine.

Instagram.users.info = function(params) {
  var credentials;
  credentials = this.parent._credentials(params, 'access_token');
  params['path'] = "/" + this.parent._api_version + "/users/" + params['user_id'] + "?" + (this.parent._to_querystring(credentials));
  return this.parent._request(params);
};

http://instagram.com/developer/endpoints/users/#get_users

dbrand666 commented 11 years ago

I'm seeing the same here. Is there any reason the param handling for these 2 methods is special?

info: (params) -> credentials = @parent._credentials {} params['path'] = "/#{@parent._api_version}/users/#{params['user_id']}?#{@parent._to_querystring(credentials)}" @parent._request params

search: (params) -> params = @parent._credentials params params['path'] = "/#{@parent._api_version}/users/search?#{@parent._to_querystring(params)}" @parent._request params

Changing then to:

info: (params) -> params = @parent._credentials params, 'access_token' params['path'] = "/#{@parent._api_version}/users/#{params['user_id']}?#{@parent._to_querystring(params)}" @parent._request params

search: (params) -> params = @parent._credentials params, 'access_token' params['path'] = "/#{@parent._api_version}/users/search?#{@parent._to_querystring(params)}" @parent._request params

... would seem to do the trick.

mckelvey commented 11 years ago

Thanks guys — pull request merged. :)

dbrand666 commented 11 years ago

Thanks! I really appreciate your hard work and how quickly you turned this around.

Can you push this change to npm?

mckelvey commented 11 years ago

Thanks for the reminder — done — v 0.1.1.