Integrating Redmine with Yammer or how to make a GET request
Added by Vitaly Tychenok over 11 years ago
Hello
I have a task to integrate Yammer into Redmine 1.0.3
The easiest way is to use Gems Yam, Yammer, Yammer-oauth2 or Omniauth-yammer. But I can't do it for various reasons. But all of them associated with Gems versions and their incompatibility with those that Redmine 1.0.3 need:
Ruby - v 1.8.7, Rails -v 2.3.5, Gem -v 1.4.0 and Rack -v 1.0.1
Please help me to get access token from Yammer.
Here is a step by step description of the Yammer authorization process:
1. Construct the following URL using the client_id you received after registering your app with Yammer: https://www.yammer.com/dialog/oauth?client_id=[:client_id]
2. Follow the URL you constructed above. It will take you to a Yammer OAuth dialog. Click the "Allow" button.
3. You will be redirected to a URL that looks something like this: http://[:redirect_uri]?code=[:code]
4. Use the code from step 3 along with your client_id and client_secret (obtained when registering your app) to construct the following URL: https://www.yammer.com/oauth2/access...son?client_id=[:client_id]&client_secret=[:client_secret]&code=[:code]
5. The authorization server will return an access token object as part of a broader response that includes user profile information.
Theoretically it's simple) But I can't get the value of code in step 3.I tried:
- require 'oauth2'
- client = OAuth2::Client.new('Client ID', 'Secret key', :site => 'https://www.yammer.com', :authorize_url => "/dialog/oauth", :token_url => "/oauth2/access_token.json", :token_method => :get)
- auth_url = client.auth_code.authorize_url(:redirect_uri => 'http://localhost:3000/auth/yammer/callback')
- url = URI.parse auth_url
- response = client.request(:get, url.path, {:params => url.query})
But in response I received a Redirection on https://www.yammer.com/dialog/authenticate
What am I doing wrong?
Thanks