Class: YammerOAuth2::Client
- Inherits:
-
OAuth2::Client
- Object
- OAuth2::Client
- YammerOAuth2::Client
- Defined in:
- lib/yammer-oauth2/client.rb
Constant Summary collapse
- DEFAULT_URL =
'https://www.yammer.com'
Instance Method Summary collapse
-
#clientside_authorization_url(opts = {}) ⇒ Object
Generates the Yammer URL that the user will be redirected to in order to authorize your application.
-
#exchange_auth_code_for_token(code, opts = {}) ⇒ Object
client_id=client_id&code=G3Y6jU3a&grant_type=authorization_code& redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fcb&client_secret=client_secret.
-
#initialize(client_id, client_secret, opts = {}) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
-
#webserver_authorization_url(opts = {}) ⇒ Object
Generates the Yammer URL that the user will be redirected to in order to authorize your application.
-
#webserver_token_path(code, opts = {}) ⇒ Object
Generates the Yammer URL that the user will be redirected to in order to authorize your application.
Constructor Details
#initialize(client_id, client_secret, opts = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 |
# File 'lib/yammer-oauth2/client.rb', line 8 def initialize(client_id, client_secret, opts={}) site_url = opts.delete(:site_url) || DEFAULT_URL super(site_url, client_id, client_secret, opts) @token_path = '/oauth2/access_token' @authorize_path = '/dialogs/oauth' yield self if block_given? self end |
Instance Method Details
#clientside_authorization_url(opts = {}) ⇒ Object
Generates the Yammer URL that the user will be redirected to in order to authorize your application
client = YammerClient.new(config) client.clientside_authorization_url({
:redirect_uri => 'https://localhost/oauth/cb',
})
>> www.yammer.com/dialog/oauth/?client_id=client_id&
redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fcb&response_type=token
31 32 33 |
# File 'lib/yammer-oauth2/client.rb', line 31 def (opts={}) implicit.token_url(opts) end |
#exchange_auth_code_for_token(code, opts = {}) ⇒ Object
client_id=client_id&code=G3Y6jU3a&grant_type=authorization_code&
redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fcb&client_secret={client_secret}
98 99 100 101 102 103 |
# File 'lib/yammer-oauth2/client.rb', line 98 def exchange_auth_code_for_token(code, opts={}) opts[:authenticate] ||= :body opts[:params] = {} opts[:params][:redirect_uri] = opts.delete(:redirect_uri) .get_token(code, opts) end |
#webserver_authorization_url(opts = {}) ⇒ Object
Generates the Yammer URL that the user will be redirected to in order to authorize your application
>> client = YammerClient.new(config) >> client.webserver_authorization_url({
:redirect_uri => 'https://localhost/oauth/cb',
})
>> www.yammer.com/dialog/oauth/?client_id=client_id&
redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fcb&response_type=code
49 50 51 52 |
# File 'lib/yammer-oauth2/client.rb', line 49 def (opts={}) opts[:scope] = normalize_scope(opts[:scope]) if opts[:scope] .(opts) end |
#webserver_token_path(code, opts = {}) ⇒ Object
Generates the Yammer URL that the user will be redirected to in order to authorize your application
>> client = YammerClient.new(config) >> client.webserver_token_url({
:client_secret => @client_secret
:code => 'G3Y6jU3a',
:redirect_uri => 'https://localhost/oauth/cb',
})
>> www.yammer.com/oauth2/access_token?client_id=client_id&
redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fcb&client_secret={client_secret}&
grant_type=authorization_code&code=aXW2c6bYz
71 72 73 74 75 76 |
# File 'lib/yammer-oauth2/client.rb', line 71 def webserver_token_path(code, opts={}) opts[:code] = code opts[:scope] = normalize_scope(opts[:scope]) if opts[:scope] opts[:client_secret] = @client_secret .token_path(opts) end |