def register():

    okta_util = OktaUtil(request.headers)

    first_name = request.form["firstName"]
    last_name = request.form["lastName"]
    email = request.form["email"]
    mobile = request.form["mobile"]
    password = request.form["password"]

    user_info = okta_util.create_user(first_name=first_name,
                                      last_name=last_name,
                                      email=email,
                                      phone=mobile,
                                      password=password)
    print user_info
    user_id = user_info["id"]

    # Authenticate
    auth_response = okta_util.authenticate(username=email, password=password)
    session[okta_util.OKTA_SESSION_TOKEN_KEY] = auth_response["sessionToken"]

    factor_response = okta_util.create_sms_factor(user_id=user_id, phone_number=mobile)
    activate_url = factor_response["_links"]["activate"]["href"]

    # Activate
    activate_response = okta_util.activate_sms_factor(url=activate_url)

    return json.dumps(activate_response)
def create_user():
    print "create_user"
    okta_util = OktaUtil(request.headers)

    first_name = request.form["firstName"]
    last_name = request.form["lastName"]
    email = request.form["email"]
    mobile = request.form["mobile"]
    password = request.form["password"]

    user_info = okta_util.create_user(first_name=first_name,
                                      last_name=last_name,
                                      email=email,
                                      phone=mobile,
                                      password=password)

    return json.dumps(user_info)