Google License API分配归档许可证时出现503 backendError问题排查
分配Google Workspace归档许可证时遭遇503 Backend Error
当前遇到以下错误:
Error managing archive license for xxxx@domain.com: <HttpError 503 when requesting https://licensing.googleapis.com/apps/licensing/v1/product/101034/sku/1010340001/user?alt=json returned "Backend Error". Details: "[{'message': 'Backend Error', 'domain': 'global', 'reason': 'backendError'}]">
该错误仅在尝试为用户分配Google Workspace归档用户许可证时出现。若为用户分配活跃许可证,代码可完美执行,无任何错误(尤其是此503 - 'backendError')。我正在尝试自动撤销用户的活跃许可证并为其分配新的归档许可证。
这是Google的内部问题,还是我的代码块存在错误?
SKU_MAP_TO_ARCHIVE = { '1010020020': '1010340001' # Google Workspace Enterprise Plus -> Enterprise Plus - Archived User } ACTIVE_PRODUCT_ID = 'Google-Apps' ARCHIVE_PRODUCT_ID = 101034 PRODUCT_IDS_TO_CHECK = list(set([ACTIVE_PRODUCT_ID])) def change_user_license_to_archive(user_email, current_sku_id): """Changes a user's active license to an appropriate archive license.""" credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES, subject='xxxSuperADMIN@domain.com') licensing_service = build('licensing', 'v1', credentials=credentials) if not licensing_service: print(f"Error: Licensing API service could not be built for license change for {user_email}.") return False print("valid licenseing service") archive_sku_id = SKU_MAP_TO_ARCHIVE.get(current_sku_id) if not archive_sku_id: print(f"Error: No archive SKU mapped for current SKU ID {current_sku_id} for user {user_email}.") return False try: # Determine the correct product ID for deleting the current license # Most active Workspace licenses are under 'Google-Apps' product ID # If the current SKU ID is already an 'archived user' SKU, then use ARCHIVE_PRODUCT_ID (101034) delete_product_id = ACTIVE_PRODUCT_ID if current_sku_id in SKU_MAP_TO_ARCHIVE.values(): delete_product_id = ARCHIVE_PRODUCT_ID print(f"Attempting to revoke active license ({current_sku_id}) for {user_email} (Product ID for deletion: {delete_product_id})...") licensing_service.licenseAssignments().delete( productId=delete_product_id, skuId=current_sku_id, userId=user_email ).execute() print(f"Successfully revoked active license for {user_email}.") # Assign the archive license print(f"Attempting to assign archive license ({archive_sku_id}) for {user_email} (Product ID for assignment: {ARCHIVE_PRODUCT_ID})...") licensing_service.licenseAssignments().insert( body={ 'userId': user_email, }, productId=101034, skuId=1010340001, # archive sku id ).execute() print(f"Successfully assigned archive license for {user_email}.") return True except Exception as e: print(f"Error managing archive license for {user_email}: {e}") return False
我已尝试在HTTP请求中同时以字符串和整数形式传递productId和skuId,但在尝试为用户分配归档许可证时仍会收到503错误。想了解这是Google内部问题,还是我的环境中缺少某些配置。
内容的提问来源于stack exchange,提问作者Morgan Molyneaux
相关产品推荐
相关产品推荐

