def with_scopes(credentials, scopes):
 if (HAS_GOOGLE_AUTH and isinstance(credentials, google.auth.credentials.Credentials)):
  return google.auth.credentials.with_scopes_if_required(credentials, scopes)
 else:
  try:
   if credentials.create_scoped_required():
    return credentials.create_scoped(scopes)
   else:
    return credentials
  except AttributeError:
   return credentials

def with_scopes ( credentials , scopes ) : if ( HAS_GOOGLE_AUTH and isinstance ( credentials , google . auth . credentials . Credentials ) ) : return google . auth . credentials . with_scopes_if_required ( credentials , scopes ) else : try : if credentials . create_scoped_required ( ) : return credentials . create_scoped ( scopes ) else : return credentials except AttributeError : return credentials
scopes the credentials if necessary .