88
99import json , requests
1010from flask import Blueprint , request , redirect , jsonify , url_for , session
11- from .exeptions import Flask_ONEID_Exception
11+ from .exceptions import Flask_ONEID_Exception
1212class OneID :
13- __oneid_url__ = "https://sso.egov.uz/sso/oauth/Authorization.do"
14- __callbakc_url__ = "/"
15- __one_id_keys = []
13+
1614 ONEID_LOGIN_URL = "/oneid/login"
1715 def __init__ (self , app = None ):
1816 if app is not None :
@@ -29,6 +27,9 @@ def init_app(self, app) -> None:
2927
3028
3129 """
30+ self .__oneid_url__ = "https://sso.egov.uz/sso/oauth/Authorization.do"
31+ self .__callback_url = "/"
32+ self .__one_id_keys = []
3233 self .__client_id__ = app .config .get ('ONEID_LOGIN' )
3334 if self .__client_id__ is None :
3435 raise Flask_ONEID_Exception ("ONEID_LOGIN is not set, please set it in config.py" )
@@ -53,10 +54,9 @@ def get_user_data():
5354 elif type (value ) == list :
5455 for item in value :
5556 params += key + "=" + item + "&"
56- return redirect (self .__callbakc_url__ + params )
57+ return redirect (self .__callback_url + params )
5758 @oneid .route ('/auth' , methods = ['GET' ])
5859 def oneid_auth ():
59- #return jsonify(request.args)
6060 code = request .args .get ('code' )
6161 self .__oneid_authorize__ = self .__oneid_url__ + "?grant_type=one_authorization_code&client_id=%s&client_secret=%s&redirect_uri=%s&code=%s" % (self .__client_id__ ,self .__client_secret__ ,self .__redirect__ ,code )
6262 x = requests .post (self .__oneid_authorize__ )
@@ -90,6 +90,10 @@ def Set_Callback(self, callback_url):
9090 Args:
9191 callback_url (string): Callback url for redirect with data from OneID
9292 """
93- self .__callbakc_url__ = callback_url
93+ self .__callback_url = callback_url
94+ @property
95+ def oneid_login (self ):
96+ return self .ONEID_LOGIN_URL
97+
9498
9599
0 commit comments