src/foggycam.py
def initialize_twof_session(self, time_token):
        """Creates the first session to get the access token and cookie, with 2FA enabled."""

        print ("Intializing 2FA session...")

        target_url = self.nest_session_url + "?=_" + time_token
        print (target_url)

        try:
            request = urllib.request.Request(target_url)
            request.add_header('Authorization', 'Basic %s' % self.nest_access_token)

            response = self.merlin.open(request)
            session_data = response.read()

            session_json = json.loads(session_data)

            self.nest_access_token = session_json['access_token']
            self.nest_access_token_expiration = session_json['expires_in']
            self.nest_user_id = session_json['userid']

            self.pickle_cookies()
        except urllib.request.HTTPError as err:
            print (err)
Creates the first session to get the access token and cookie, with 2FA enabled.
Creates the first session to get the access token and cookie, with 2FA enabled.
Creates the first session to get the access token and cookie with 2FA enabled .
def initialize_twof_session(self, time_token):
        print ("Intializing 2FA session...")
        target_url = self.nest_session_url + "?=_" + time_token
        print (target_url)
        try:
            request = urllib.request.Request(target_url)
            request.add_header('Authorization', 'Basic %s' % self.nest_access_token)
            response = self.merlin.open(request)
            session_data = response.read()
            session_json = json.loads(session_data)
            self.nest_access_token = session_json['access_token']
            self.nest_access_token_expiration = session_json['expires_in']
            self.nest_user_id = session_json['userid']
            self.pickle_cookies()
        except urllib.request.HTTPError as err:
            print (err)
def initialize_twof_session ( self , time_token ) : print ( "Intializing 2FA session..." ) target_url = self . nest_session_url + "?=_" + time_token print ( target_url ) try : request = urllib . request . Request ( target_url ) request . add_header ( 'Authorization' , 'Basic %s' % self . nest_access_token ) response = self . merlin . open ( request ) session_data = response . read ( ) session_json = json . loads ( session_data ) self . nest_access_token = session_json [ 'access_token' ] self . nest_access_token_expiration = session_json [ 'expires_in' ] self . nest_user_id = session_json [ 'userid' ] self . pickle_cookies ( ) except urllib . request . HTTPError as err : print ( err )
Creates the first session to get the access token and cookie, with 2FA enabled.
Creates the first session to get the access token and cookie with 2FA enabled .
"""Creates the first session to get the access token and cookie, with 2FA enabled."""
self
time_token