Integration with External Auth Providers
There are cases, when your website already has a social login or some form identity management in place. If this is the case, there is no need to replace authentication provider, but including a simple webhook like call to Tradable Bits will allow us to track properly identity of the user and target them properly in the system. Same approach can be taken, when integrating with native mobile apps
Call will require following arguments
args = {
"network":"facebook",
"access_token" : xxxx,
"device_network": "ios",
"device_id": "xxx"
}
requests.post("https://tradablebits.com/api/v1/sessions/connect",args)
For more details, please check API documentation and native examples
Integration with Websites for Festivals
Tradable Bits Platform consumes fan data from various sources and Festival Website is very important source to be ignored. Social Login, Schedule, and ability to create personal schedule are highly expected and used features, so our API allows fully integrate and build entire user experience without having to resort to building full development Environment.
Terms and Values we will reference in the example
https://www.festival.com | Link to your Festival Website |
https://www.festival.com/auth_callback | Authentication Callback, which will handle authentication |
Python | Server Side language used in the example. Obviously, you're not restricted to stay with python |
Login Network Used in the example. We support third party networks like Meta, Google, etc, but in this example authentication is performed with Tradable Bits Login. | |
api_secret | API Secret will be required to map back "code" from callback to session_uid, which can be used in the API |
api_key | As per our reference, api_key is used for call with RESTful API together with session_uid |
Login Integration
There is more than one way to integrate authentication into website. In this example we will utilize OAUTH mechanism. Javascript SDK is also available and can be used if desired.
First, you need to add links with social auth on your website:
<a href="https://tradablebits.com/crm/oauth?account_id=xxxx&business_id=xxxx&login_type=email&redirect_url=https://wwww.festival.com/auth_callback"> Connect with Email </a>
On your Auth Call back Code, redirect will include code
def process_response():
code = request.args.get('code')
error = request.args.get('error')
if error is not None:
handle_error(error)
elif code is not None:
code = request.args.get('code')
api_key = "12345"
account_id = "12345"
redirect_url = "http://www.festival.com/auth_callback"
parms = {"code":code,"api_key":api_key,"account_id":account_id,"redirect_url":redirect_url}
token_url = "https://tradablebits.com/crm/access_token?%s" % urllib.urlencode(parms)
with contextlib.closing(urllib2.urlopen(token_url, timeout=10)) as r:
res = r.read()
session = json.loads(res)
session_uid = session['session_uid']
fan_id = session['fan_id']
handle_session(session_uid,fan_id)
With Valid session_uid, you can start querying API for the list of artists in the line up and optionally their schedules
Idols and Line up
Existing Artists for the line up can be retrieved with public keyurl = "https://tradablebits.com/api/v1/idols?api_key=xxxxx&label_name=myfest2019"
Existing Events for the festival
url = "https://tradablebits.com/api/v1/idols/events?api_key=xxxxx&label_name=myfest2019"
Fetching list of liked idols
url = "https://tradablebits.com/api/v1/sessions/" + session_uid + "/idols?api_key=xxxxx&label_name=myfest2019"
Adding Idol into "liked"
url = "https://tradablebits.com/api/v1/sessions/" + session_uid + "/idols?api_key=xxxxx"
args = {"action":"add","idol_uid": "xxxx"}
requests.post(url,args)