@@ -33,8 +33,9 @@ class Auth:
33
33
:param requests: Session to make HTTP requests
34
34
35
35
:type client_secret: str or dict
36
- :param client_secret: (Optional) Dict object from social client
37
- secret file, defaults to :data:`None`.
36
+ :param client_secret: (Optional) File path to or the dict object
37
+ from social client secret file, defaults to :data:`None`.
38
+
38
39
"""
39
40
40
41
def __init__ (self , api_key , credentials , requests , client_secret = None ):
@@ -49,7 +50,7 @@ def __init__(self, api_key, credentials, requests, client_secret=None):
49
50
self .session_id = None
50
51
51
52
if client_secret :
52
- self .client_secret = client_secret
53
+ self .client_secret = _load_client_secret ( client_secret )
53
54
54
55
def create_authentication_uri (self , provider_id ):
55
56
""" Creates an authentication URI for the given social
@@ -446,3 +447,22 @@ def update_profile(self, id_token, display_name=None, photo_url=None, delete_att
446
447
raise_detailed_error (request_object )
447
448
448
449
return request_object .json ()
450
+
451
+
452
+ def _load_client_secret (secret ):
453
+ """ Load social providers' client secret from file if file path
454
+ provided.
455
+
456
+ :type secret: str or dict
457
+ :param secret: File path to or the dict object from social client
458
+ secret file.
459
+
460
+ :return: social client secret
461
+ :rtype: dict
462
+ """
463
+
464
+ if type (secret ) is str :
465
+ with open (secret ) as file :
466
+ secret = json .load (file )
467
+
468
+ return secret
0 commit comments