Class: RubyPushNotifications::WNS::WNSAccess
- Inherits:
-
Object
- Object
- RubyPushNotifications::WNS::WNSAccess
- Defined in:
- lib/ruby-push-notifications/wns/wns_access.rb
Overview
This class is responsible for get access auth token for sending pushes
Defined Under Namespace
Classes: Response
Constant Summary collapse
- GRANT_TYPE =
'client_credentials'.freeze
- SCOPE =
'notify.windows.com'.freeze
- ACCESS_TOKEN_URL =
'https://login.live.com/accesstoken.srf'.freeze
Instance Attribute Summary collapse
-
#secret ⇒ String
readonly
. Secret token.
-
#sid ⇒ String
readonly
. Sid.
Instance Method Summary collapse
-
#get_token ⇒ Object
Get access auth token for sending pushes.
-
#initialize(sid, secret) ⇒ WNSAccess
constructor
You can get it on account.live.com/developers/applications/index.
Constructor Details
#initialize(sid, secret) ⇒ WNSAccess
You can get it on account.live.com/developers/applications/index
56 57 58 59 |
# File 'lib/ruby-push-notifications/wns/wns_access.rb', line 56 def initialize(sid, secret) @sid = sid @secret = secret end |
Instance Attribute Details
#secret ⇒ String (readonly)
Returns . Secret token.
50 51 52 |
# File 'lib/ruby-push-notifications/wns/wns_access.rb', line 50 def secret @secret end |
#sid ⇒ String (readonly)
Returns . Sid.
47 48 49 |
# File 'lib/ruby-push-notifications/wns/wns_access.rb', line 47 def sid @sid end |
Instance Method Details
#get_token ⇒ Object
Get access auth token for sending pushes
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ruby-push-notifications/wns/wns_access.rb', line 64 def get_token body = { grant_type: GRANT_TYPE, client_id: sid, client_secret: secret, scope: SCOPE } url = URI.parse ACCESS_TOKEN_URL http = Net::HTTP.new url.host, url.port http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER response = http.post url.request_uri, URI.encode_www_form(body) Response.new response end |