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

undefined method `downcase' for nil:NilClass #51

Closed
angelacode opened this issue Apr 26, 2011 · 20 comments
Closed

undefined method `downcase' for nil:NilClass #51

angelacode opened this issue Apr 26, 2011 · 20 comments

Comments

@angelacode
Copy link

Why am I getting this error? I get the atoken and asecret from the authentication hash after using OmniAuth. Seems okay, but then when I try to access the profile method, it borks:

  8     @user = User.find(params[:id]) 
  9     @client = LinkedIn::Client.new(ENV["LINKEDIN_KEY"], ENV["LINKEDIN_SECRET"]) 
 10     @client.authorize_from_access(@user.atoken, @user.asecret) 
 11     if @user == current_user 
 12       @client.profile 
 13     else 
 14       @client.profile(:id => @user.uid) 
 15     end 
 16   end 
@renatosnrg
Copy link
Contributor

Hi Angela,

I've made a pull request to solve this issue.

I hope it can help you!

@simonmorley
Copy link

Hi

I'm still having this issue with latest build. How can I fix?

Thanks

Simon

@renatosnrg
Copy link
Contributor

My pull request is not merged yet. You can try my fork until my pull request (or other fix) is not applied to the current master.

@simonmorley
Copy link

Thanks for the message. I get no errors with your fork but also strangely, no output?! Any suggestions?

@renatosnrg
Copy link
Contributor

Can you post your code here? I'm using with no problems in my production environment.

@simonmorley
Copy link

Hi, sorry for the delay, I wasn't notified about a reply!

Linkedin Model:

require 'linkedin'
class LinkedinToken < ConsumerToken
def client
client = LinkedIn::Client.new(LinkedinToken.consumer.key, LinkedinToken.consumer.secret)
client.authorize_from_access(token, secret)
@client = client.profile
end
end

show:


Linkedin: <% @user.linkedin_token.client %>

I think it's a ruby error and nothing to do with your gem but I really appreciate your help :)

@simonmorley
Copy link

Got it working, think there was a typo. Still a little confused though - I end us with a linkedin::mash not a hashie and have no idea how to get the data out?

@renatosnrg
Copy link
Contributor

You can get the fields directly using LinkedIn::Mash:

profile = client.profile
first_name = profile.first_name
current_position = profile.positions.all.find{|pos| pos.is_current == true} unless profile.positions.all.nil?
profile.picture_url

@marckohlbrugge
Copy link

I was having the same problem (using OmniAuth like Simon and Angela), but your fork fixed it Renato. Thanks! Hope it gets merged with the master soon.

@jeremyw
Copy link

jeremyw commented Jul 31, 2011

What's going on with this? I'm seeing the same error. It looks like omniauth is not using the entire API endpoint, just a relative path.

@marckohlbrugge
Copy link

@jeremyw, see here: #55

@rtlong
Copy link

rtlong commented Aug 1, 2011

I can confirm that @renatosnrg's pull request fixed it. Specifically, all I needed was one commit: renatosnrg/linkedin@90b6641

@javan
Copy link
Contributor

javan commented Aug 3, 2011

This just bit me too.

>> client = LinkedIn::Client.new(API_KEY, API_SECRET)
>> client.authorize_from_access(ACCESS_TOKEN, ACCESS_SECRET)
>> client.profile
NoMethodError: undefined method `downcase' for nil:NilClass
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/request_proxy/base.rb:93:in `normalized_uri'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/request_proxy/base.rb:113:in `signature_base_string'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/signature/base.rb:77:in `signature_base_string'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/signature/hmac/base.rb:12:in `digest'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/signature/base.rb:65:in `signature'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/signature.rb:23:in `sign'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/client/helper.rb:45:in `signature'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/client/helper.rb:75:in `header'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/client/net_http.rb:91:in `set_oauth_header'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/client/net_http.rb:30:in `send'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/client/net_http.rb:30:in `oauth!'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/consumer.rb:227:in `sign!'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/consumer.rb:191:in `create_signed_request'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/consumer.rb:162:in `request'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/tokens/consumer_token.rb:25:in `request'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/tokens/access_token.rb:12:in `request'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/oauth-0.4.5/lib/oauth/tokens/access_token.rb:27:in `get'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/linkedin-0.3.1/lib/linked_in/helpers/request.rb:15:in `get'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/linkedin-0.3.1/lib/linked_in/api/query_methods.rb:32:in `simple_query'
    from /Users/javan/.rvm/gems/ruby-1.8.7-p334/gems/linkedin-0.3.1/lib/linked_in/api/query_methods.rb:8:in `profile'
    from (irb):10

@huned
Copy link
Contributor

huned commented Aug 5, 2011

more productively: +1 for @renatosnrg's pull request! :)

@comp615
Copy link

comp615 commented Aug 21, 2011

+1 please merge this in!

@lstone
Copy link

lstone commented Aug 27, 2011

Please merge this!

@thoughtpunch
Copy link

MERGE!!@!#!@#!@#!

@johnsome
Copy link

johnsome commented Sep 1, 2011

+1 please merge

@Phiction
Copy link

Phiction commented Sep 3, 2011

+1 for merge

@ryanatwork
Copy link
Collaborator

This has been fixed in the last merge.

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