@@ -33,8 +33,9 @@ class Auth:
3333 :param requests: Session to make HTTP requests
3434
3535 :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+
3839 """
3940
4041 def __init__ (self , api_key , credentials , requests , client_secret = None ):
@@ -49,7 +50,7 @@ def __init__(self, api_key, credentials, requests, client_secret=None):
4950 self .session_id = None
5051
5152 if client_secret :
52- self .client_secret = client_secret
53+ self .client_secret = _load_client_secret ( client_secret )
5354
5455 def create_authentication_uri (self , provider_id ):
5556 """ 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
446447 raise_detailed_error (request_object )
447448
448449 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