Module: BWAPI::Client::OAuth
- Included in:
- BWAPI::Client
- Defined in:
- lib/bwapi/client/oauth.rb
Instance Method Summary collapse
-
#oauth_refresh_token(opts = {}, refresh_token = nil) ⇒ Object
(also: #refresh)
Refresh a authenticated users oauth_token.
-
#oauth_request(opts) ⇒ Object
Sends a oauth request.
-
#oauth_token(opts = {}) ⇒ Object
(also: #login)
Authenticate a user.
Instance Method Details
#oauth_refresh_token(opts = {}, refresh_token = nil) ⇒ Object Also known as: refresh
Refresh a authenticated users oauth_token
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bwapi/client/oauth.rb', line 36 def oauth_refresh_token opts={}, refresh_token = nil opts = { username: username, password: password, refresh_token: refresh_token, grant_type: 'refresh_token', client_id: client_id, force_urlencoded: true }.merge opts oauth_request opts end |
#oauth_request(opts) ⇒ Object
Sends a oauth request
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/bwapi/client/oauth.rb', line 53 def oauth_request opts begin creds = post 'oauth/token', opts rescue BWAPI::BWError false else self.access_token = creds.access_token self.expires_in = creds.expires_in if application_client? self.refresh_token = creds.refresh_token end true end end |
#oauth_token(opts = {}) ⇒ Object Also known as: login
Authenticate a user
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bwapi/client/oauth.rb', line 14 def oauth_token opts={} opts = { username: username, password: password, grant_type: 'password', client_secret: client_secret, client_id: client_id, force_urlencoded: true }.merge opts oauth_request opts end |