def authenticate(self, code: str) -> 'Preston':
        """Authenticates using the code from the EVE SSO.

        A new Preston object is returned; this object is not modified.

        The intended usage is:

            auth = preston.authenticate('some_code_here')

        Args:
            code: SSO code

        Returns:
            new Preston, authenticated
        """
        headers = self._get_authorization_headers()
        data = {
            'grant_type': 'authorization_code',
            'code': code
        }
        r = self.session.post(self.TOKEN_URL, headers=headers, data=data)
        if not r.status_code == 200:
            raise Exception(f'Could not authenticate, got repsonse code {r.status_code}')
        new_kwargs = dict(self._kwargs)
        response_data = r.json()
        new_kwargs['access_token'] = response_data['access_token']
        new_kwargs['access_expiration'] = time.time() + float(response_data['expires_in'])
        new_kwargs['refresh_token'] = response_data['refresh_token']
        return Preston(**new_kwargs)
def authenticate ( self , code : str ) -> 'Preston' : headers = self . _get_authorization_headers ( ) data = { 'grant_type' : 'authorization_code' , 'code' : code } r = self . session . post ( self . TOKEN_URL , headers = headers , data = data ) if not r . status_code == 200 : raise Exception ( f'Could not authenticate, got repsonse code {r.status_code}' ) new_kwargs = dict ( self . _kwargs ) response_data = r . json ( ) new_kwargs [ 'access_token' ] = response_data [ 'access_token' ] new_kwargs [ 'access_expiration' ] = time . time ( ) + float ( response_data [ 'expires_in' ] ) new_kwargs [ 'refresh_token' ] = response_data [ 'refresh_token' ] return Preston ( ** new_kwargs )
Authenticates using the code from the EVE SSO.

        A new Preston object is returned; this object is not modified.

        The intended usage is:

            auth = preston.authenticate('some_code_here')

        Args:
            code: SSO code

        Returns:
            new Preston, authenticated