code: def make_from_response(
          cls,
          response,
          grant_type,
          client_id,
          client_secret=None,
          redirect_url=None,
      ):
          
          if response.status_code != codes.ok:
              message = 'Error with Access Token Request: {}'
              message = message.format(response.reason)
              raise ClientError(response, message)
  
          response = response.json()
  
          # convert space delimited string to set
          scopes = response.get('scope')
          scopes_set = {scope for scope in scopes.split()}
  
          return cls(
              client_id=client_id,
              client_secret=client_secret,
              redirect_url=redirect_url,
              access_token=response.get('access_token'),
              expires_in_seconds=response.get('expires_in'),
              scopes=scopes_set,
              grant_type=grant_type,
              refresh_token=response.get('refresh_token', None),
          )
docs: Alternate constructor for OAuth2Credential().
  
          Create an OAuth2Credential from an HTTP Response.
  
          Parameters
              response (Response)
                  HTTP Response containing OAuth 2.0 credentials.
              grant_type (str)
                  Type of OAuth 2.0 Grant used to obtain access token.
                  (e.g. 'authorization_code')
              client_id (str)
                  Your app's Client ID.
              client_secret (str)
                  Your app's Client Secret.
              redirect_url (str)
                  The URL that the Uber server will redirect to.
  
          Returns
              (OAuth2Credential)
  
          Raises
              ClientError (APIError)
                  Raised if the response is invalid.