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

Yammer no longer raise Unauthorized, instead returns string "Authenticated Failure" #34

Open
synth opened this issue Jul 4, 2014 · 8 comments

Comments

@synth
Copy link

synth commented Jul 4, 2014

Its our understanding the yam gem should raise an Unauthorized exception when a request is made that is, um, unauthorized.

However, we've noticed recently that unauthorized requests are just return the string "Authenticated Failure" which is wrong because a) its not valid json b) it should be raising an exception.

Looking through the codebase, it looks like the only reference to Unauthorized is in error.rb#from_status method which I don't see being called from anywhere.

What is the proper way to handle unauthorized requests?

@synth
Copy link
Author

synth commented Jul 4, 2014

Looks like its jumping into this line: https://github.com/yammer/yam/blob/master/lib/yammer/http_adapter.rb#L86

How is this supposed to work? By catching the rest exception and merely returning a string, it makes it difficult and brittle to switch behavior on the response type.

@tiabas
Copy link
Contributor

tiabas commented Jul 15, 2014

Would you mind posting a sample code for the kind of request in question. It would make it a lot easier to trace the root of the problem

@synth
Copy link
Author

synth commented Jul 16, 2014

To reproduce:

  1. Obtain a valid yammer oauth token via oauth flow
  2. Make any api request with:
  yc = Yammer::Client.new(access_token: "access_token")
  yc.current_user
    #=>  #<Yammer::ApiResponse:0x0000010d51bd10...
  1. In yammer, visit profile, edit profile, go to my applications, revoke access to the application.
  2. Repeat api request
yc.current_user
=> "Authentication failure."

Expected: Yammer::ApiResponse
Actual: String

@alexspeller
Copy link

I am experiencing this too.

Yammer::Client.new.all_users

This should definitely raise an exception, it's pretty insane to return a string and have to inspect the type of the response to see if it worked or not.

@robertIngrum
Copy link

Is this gem just abandoned? This seems like a fairly important issue that still hasn't been addressed.

@mrbriandavis
Copy link

@robertIngrum - This is a painful issue that I am going to take a look to fix soon.

@chrisbloom7
Copy link

chrisbloom7 commented Nov 30, 2016

This seems to be affecting Yammer::Resources::User.current, even when Yammer::Client#current_user works ok:

client = Yammer::Client.new(access_token: access_token)
# => #<Yammer::Client:0x007fe8e3257b18
#  @access_token="[REDACTED]",
#  @client_id="[REDACTED]",
#  @client_secret="[REDACTED]",
#  @connection_options={:max_redirects=>5, :verify_ssl=>true, :use_ssl=>true},
#  @default_headers={"Accept"=>"application/json", "User-Agent"=>"Yammer Ruby Gem 2.5.0"},
#  @http_adapter=Yammer::HttpAdapter,
#  @site_url="https://www.yammer.com">
client.current_user
# => #<Yammer::ApiResponse:0x007fe8e40460f8
#  @body=
#   "{\"type\":\"user\",\"id\":[REDACTED],\"network_id\":[REDACTED], ...}",
#  @code=200,
#  @headers=
#   {:status=>"200 OK", ...}>
client.current_user.code
# => 200
Yammer::Resources::User.current
Exception: NoMethodError: undefined method `success?' for "Authentication failure.":String
Did you mean?  succ!
--
0: /Users/chrisbloom/.rvm/gems/ruby-2.3.1@rails/gems/rest-client-1.8.0/lib/restclient/exceptions.rb:76:in `method_missing'
1: /Users/chrisbloom/.rvm/gems/ruby-2.3.1@rails/gems/yam-2.5.0/lib/yammer/resources/user.rb:22:in `current'

@IMhide
Copy link

IMhide commented Aug 24, 2017

3 years after, this issue is still goin

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

7 participants