class RubyPushNotifications::WNS::WNSAccess
This class is responsible for get access auth token for sending pushes
Constants
- ACCESS_TOKEN_URL
@private Url for getting access token
- GRANT_TYPE
@private Grant type for getting access token
- SCOPE
@private Scope for getting access token
Attributes
secret[R]
@return [String]. Secret token
sid[R]
@return [String]. Sid
Public Class Methods
new(sid, secret)
click to toggle source
@param type [String]. Sid @param type [String]. Secret
You can get it on account.live.com/developers/applications/index
# File lib/ruby-push-notifications/wns/wns_access.rb, line 56 def initialize(sid, secret) @sid = sid @secret = secret end
Public Instance Methods
get_token()
click to toggle source
Get access auth token for sending pushes
# 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