code: def _get_external_id(account_info):
      
      if all(k in account_info for k in ('external_id', 'external_method')):
          return dict(id=account_info['external_id'],
                      method=account_info['external_method'])
      return None
docs: Get external id from account info.