If you don't find an answer, please click here to post your question.
Reply
Highlighted
Occasional Advisor
Posts: 9
Registered: ‎01-03-2018
Accepted Solution

Generate signing request iOS

How is the best way to generate ooyala signing request for ios? 

Could you give me an example?

 

thanks


Accepted Solutions
Ooyalan
Posts: 13
Registered: ‎10-09-2017

Re: Generate signing request iOS

Hello,

 

You can use an HTTP CALL with native URLSession or AFnetworking and you also need to follow the steps in order to generate the signature and sent the HTTPS Request. 

 

 

Here is some information in order to know How to generate the Signature

http://help.ooyala.com/video-platform/tasks/api_signing_requests.html

 

Some code examples

http://help.ooyala.com/video-platform/tasks/api_signing_requests_appendix.html

 

Also here  a code example on Python please notice that you need to SORT the Query Params

import datetime
import hashlib
import base64
import urllib

class ooyala_api(object):
def generate_signature(self, secret_key, http_method, request_path, query_params, request_body=''):
signature = secret_key + http_method.upper() + request_path
for key, value in sorted(query_params.iteritems()):
signature += key + '=' + str(value)

signature = signature.encode('ascii')
signature += request_body
signature = base64.b64encode(hashlib.sha256(signature).digest())[0:43]
signature = urllib.quote_plus(signature)
return signature


API_KEY = ' YOUR API KEY'
API_SECRET = 'YOUR API SECRET'
method = 'GET'
path = '/v2/assets'
expires = (datetime.datetime.now() + datetime.timedelta(days=3)).strftime('%s')
params = {
'api_key': api_key,
'expires': expires,
}

api = ooyala_api()
signature = api.generate_signature(secret, method, path, params)
query_string = urllib.urlencode(params)
request_uri = 'https://api.ooyala.com' + path + '?' + query_string + '&signature=' + signature
print request_uri

View solution in original post


All Replies
Ooyalan
Posts: 13
Registered: ‎10-09-2017

Re: Generate signing request iOS

Hello,

 

You can use an HTTP CALL with native URLSession or AFnetworking and you also need to follow the steps in order to generate the signature and sent the HTTPS Request. 

 

 

Here is some information in order to know How to generate the Signature

http://help.ooyala.com/video-platform/tasks/api_signing_requests.html

 

Some code examples

http://help.ooyala.com/video-platform/tasks/api_signing_requests_appendix.html

 

Also here  a code example on Python please notice that you need to SORT the Query Params

import datetime
import hashlib
import base64
import urllib

class ooyala_api(object):
def generate_signature(self, secret_key, http_method, request_path, query_params, request_body=''):
signature = secret_key + http_method.upper() + request_path
for key, value in sorted(query_params.iteritems()):
signature += key + '=' + str(value)

signature = signature.encode('ascii')
signature += request_body
signature = base64.b64encode(hashlib.sha256(signature).digest())[0:43]
signature = urllib.quote_plus(signature)
return signature


API_KEY = ' YOUR API KEY'
API_SECRET = 'YOUR API SECRET'
method = 'GET'
path = '/v2/assets'
expires = (datetime.datetime.now() + datetime.timedelta(days=3)).strftime('%s')
params = {
'api_key': api_key,
'expires': expires,
}

api = ooyala_api()
signature = api.generate_signature(secret, method, path, params)
query_string = urllib.urlencode(params)
request_uri = 'https://api.ooyala.com' + path + '?' + query_string + '&signature=' + signature
print request_uri