diff --git a/app/APIFactory.py b/app/APIFactory.py
new file mode 100644
index 0000000..befde7e
--- /dev/null
+++ b/app/APIFactory.py
@@ -0,0 +1,92 @@
+import logging
+
+from flask import flash
+import jwt
+import requests.exceptions
+from requests.auth import AuthBase
+
+import config
+
+
+__author__ = 'hanl'
+
+logging.basicConfig(level=logging.DEBUG)
+
+
+def get(path="", **kwargs):
+    path = config.URIBuilder().addPath(path).build()
+    if kwargs and path is not "":
+        try:
+            response = requests.get(path, **kwargs)
+        except requests.exceptions.RequestException as e:
+            print e
+            flash("Connection to API server could not be established", "danger")
+            return None
+        print "the response %i:%s" % (response.status_code, str(response.content))
+        return response
+    return None
+
+
+def post(path="", **kwargs):
+    path = config.URIBuilder().addPath(path).build()
+    if 'headers' in kwargs:
+        headers = kwargs['headers']
+        headers["Content-Type"] = "application/x-www-form-urlencoded"
+    else:
+        headers = {"Content-Type": "application/x-www-form-urlencoded"}
+    kwargs['headers'] = headers
+
+    if kwargs and path is not "":
+        try:
+            response = requests.post(path, **kwargs)
+        except requests.exceptions.RequestException as e:
+            print e
+            flash("Connection to API server could not be established", "danger")
+            return None
+        print "the response %i:%s" % (response.status_code, str(response.content))
+        return response
+    return None
+
+
+def trace(path="", **kwargs):
+    path = config.URIBuilder().addPath(path).build()
+    if path is not "":
+        try:
+            return requests.request("trace", path, **kwargs)
+        except requests.exceptions.RequestException as e:
+            print e
+            flash("Connection to API server could not be established", "danger")
+            return None
+    return None
+
+
+def decrypt_openid(secret=config.SECRET_KEY, token=None):
+    values = jwt.decode(jwt=token, key=secret)
+    print "decoded values %s" % str(values)
+    return values
+
+
+def encrypt_string(secret=config.SECRET_KEY, *args):
+    jwt_string = jwt.encode(args, key=secret)
+    print "encoded string %s" % str(jwt_string)
+    return jwt_string
+
+
+class Oauth2Auth(AuthBase):
+    def __init__(self, token=None):
+        self.token = token
+
+    def __call__(self, r):
+        if self.token is not None:
+            r.headers['Authorization'] = "OAuth2 Bearer " + self.token
+        return r
+
+
+class CustomAuth(AuthBase):
+    def __init__(self, token=None):
+        self.token = token
+
+    def __call__(self, r):
+        if self.token is not None:
+            r.headers['Authorization'] = "api_token " + self.token
+        return r
