lib/yammer/oauth2_client.rb in yam-2.2.0 vs lib/yammer/oauth2_client.rb in yam-2.3.0

- old
+ new

@@ -16,12 +16,12 @@ module Yammer class OAuth2Client < OAuth2Client::Client SITE_URL = 'https://www.yammer.com' - TOKEN_PATH = '/oauth2/token' - AUTHORIZE_PATH = '/dialog/oauth' + TOKEN_PATH = '/oauth2/access_token' + AUTHORIZE_PATH = '/oauth2/authorize' def initialize(client_id, client_secret, opts={}) site_url = opts.delete(:site_url) || SITE_URL opts[:token_path] ||= TOKEN_PATH opts[:authorize_path] ||= AUTHORIZE_PATH @@ -35,15 +35,15 @@ # # @see https://developer.yammer.com/api/oauth2.html#client-side # # @opts [Hash] additional parameters to be include in URL eg. scope, state, etc # - # client = YammerClient.new(config) - # client.clientside_authorization_url({ + # >> client = Yammer::OAuth2Client.new('ETSIGVSxmgZitijWZr0G6w', '4bJZY38TCBB9q8IpkeualA2lZsPhOSclkkSKw3RXuE') + # >> client.webclient_authorization_url({ # :redirect_uri => 'https://localhost/oauth/cb', # }) - # >> https://www.yammer.com/dialog/oauth/?client_id={client_id}& + # >> https://www.yammer.com/oauth2/authorize/?client_id={client_id}& # redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fcb&response_type=token # def webclient_authorization_url(opts={}) implicit.token_url(opts) end @@ -53,15 +53,15 @@ # # @see https://developer.yammer.com/api/oauth2.html#server-side # # @opts [Hash] additional parameters to be include in URL eg. scope, state, etc # - # >> client = YammerClient.new(config) + # >> client = Yammer::OAuth2Client.new('ETSIGVSxmgZitijWZr0G6w', '4bJZY38TCBB9q8IpkeualA2lZsPhOSclkkSKw3RXuE') # >> client.webserver_authorization_url({ # :redirect_uri => 'https://localhost/oauth/cb', # }) - # >> https://www.yammer.com/dialog/oauth/?client_id={client_id}& + # >> https://www.yammer.com/oauth2/authorize/?client_id={client_id}& # redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fcb&response_type=code # def webserver_authorization_url(opts={}) opts[:scope] = normalize_scope(opts[:scope]) if opts[:scope] authorization_code.authorization_url(opts) @@ -73,13 +73,12 @@ # @see https://developer.yammer.com/api/oauth2.html#server-side # # @opts [Hash] may include redirect uri and other query parameters # # >> client = YammerClient.new(config) - # >> client.exchange_auth_code_for_token({ + # >> client.access_token_from_authorization_code('G3Y6jU3a', { # :redirect_uri => 'https://localhost:3000/oauth/v2/callback', - # :code => 'G3Y6jU3a', # }) # # POST /oauth2/access_token HTTP/1.1 # Host: www.yammer.com # Content-Type: application/x-www-form-urlencoded @@ -93,10 +92,16 @@ # Makes a request to Yammer server that will swap client credential for an access token # # @opts [Hash] parameters that will be added to URL query string # + # >> client = Yammer::OAuth2Client.new('ETSIGVSxmgZitijWZr0G6w', '4bJZY38TCBB9q8IpkeualA2lZsPhOSclkkSKw3RXuE') + # >> client.access_token_from_client_credentials({ + # :client_id => "ZitijWZr0", + # :client_secret => "F8TCBB9q8IpkeualA2lZsPhOSc" + # }) + # # POST /oauth2/access_token HTTP/1.1 # Host: www.yammer.com # Content-Type: application/x-www-form-urlencoded # # client_id={client_id}&client_secret={client_secret} @@ -107,16 +112,24 @@ # Makes a request to Yammer server that will swap resource owner credentials for an access token # # @opts [Hash] parameters that will be added to URL query string # + # >> client = Yammer::OAuth2Client.new('ETSIGVSxmgZitijWZr0G6w', '4bJZY38TCBB9q8IpkeualA2lZsPhOSclkkSKw3RXuE') + # >> client.access_token_from_client_credentials({ + # :client_id => "ZitijWZr0", + # :client_secret => "F8TCBB9q8IpkeualA2lZsPhOSc", + # :email => "user@domain.com", + # :password => "abc123" + # }) + # # POST /oauth2/access_token HTTP/1.1 # Host: www.yammer.com # Content-Type: application/x-www-form-urlencoded # # client_id={client_id}&client_secret={client_secret}&username={username}&password={passwort} def access_token_from_resource_owner_credentials(username, password, opts={}) opts[:authenticate] ||= :body self.password.get_token(username, password, opts) end end -end \ No newline at end of file +end