Skip to content

Instantly share code, notes, and snippets.

@abhionlyone
Created May 27, 2018 11:13
Show Gist options
  • Save abhionlyone/c495c77b6b0b840fc58198b956c139de to your computer and use it in GitHub Desktop.
Save abhionlyone/c495c77b6b0b840fc58198b956c139de to your computer and use it in GitHub Desktop.
require 'httparty'
require 'jwt'
require 'digest'
require 'securerandom'
require 'json'
class Skype
def initialize
@key = 'b97dfb72-1504-fadd-1b04-05efc186aaeb'
@secret = '39941866-f2dc-f1c1-9882-2edd517bed0d'
@guid = SecureRandom.uuid
@time = Time.now.to_i
end
def payload
{}
end
def generate_jwt(content)
time = @time
data = {
jti: @guid,
iss: @key,
iat: time,
sub: Digest::SHA256.hexdigest(content),
exp: time + 10
}
jwt = JWT.encode data, @secret
return jwt
end
def call
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer ' + generate_jwt(payload.to_json)
}
body = payload.to_json
url = 'https://interviews.skype.com/api/interviews'
response = HTTParty.post(url, {body: body, headers: headers})
end
end
skype = Skype.new
res = skype.call
puts res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment