错误:凭证'对象无属性'带有_subject'
我正在尝试使用服务帐户使用Google ADS API。
以下工作:
from google.ads.googleads.client import GoogleAdsClient
from google.oauth2.service_account import Credentials as ServiceAccountCreds
oauth2_client = ServiceAccountCreds.from_service_account_file(
filename=key_file, subject=developer_account,
scopes=["https://www.googleapis.com/auth/adwords"]
)
google_ads_client = GoogleAdsClient(login_customer_id=self.login_customer_id, credentials=oauth2_client,
developer_token=self.developer_token)
self.ga_service = self.google_ads_client.get_service("GoogleAdsService", version="v9")
self.ga_serice.search_stream(customer_id=self.client_customer_id, query = query)
我想对身份工作负载联合(w/o密钥)进行关注:
from google.auth import aws as google_auth_aws
from google.ads.googleads.client import GoogleAdsClient
credentials = google_auth_aws.Credentials.from_info(json_config_info) # from workload identity federation
credentials = credentials.with_scopes(["https://www.googleapis.com/auth/adwords"])
credentials = credentials.with_subject(self.developer_account)
# Build the service object.
self.google_ads_client = GoogleAdsClient(login_customer_id=self.login_customer_id, credentials=credentials,
developer_token=self.developer_token)
self.ga_service = self.google_ads_client.get_service("GoogleAdsService", version="v9")
self.ga_service.search_stream(customer_id =self.client_customer_id, query = self.query)
这会引发错误: 错误:“凭据”对象没有_subject'。
I'm trying to use Google Ads API using service account.
The following works:
from google.ads.googleads.client import GoogleAdsClient
from google.oauth2.service_account import Credentials as ServiceAccountCreds
oauth2_client = ServiceAccountCreds.from_service_account_file(
filename=key_file, subject=developer_account,
scopes=["https://www.googleapis.com/auth/adwords"]
)
google_ads_client = GoogleAdsClient(login_customer_id=self.login_customer_id, credentials=oauth2_client,
developer_token=self.developer_token)
self.ga_service = self.google_ads_client.get_service("GoogleAdsService", version="v9")
self.ga_serice.search_stream(customer_id=self.client_customer_id, query = query)
I want to to do following with Identity Workload Federation(w/o key):
from google.auth import aws as google_auth_aws
from google.ads.googleads.client import GoogleAdsClient
credentials = google_auth_aws.Credentials.from_info(json_config_info) # from workload identity federation
credentials = credentials.with_scopes(["https://www.googleapis.com/auth/adwords"])
credentials = credentials.with_subject(self.developer_account)
# Build the service object.
self.google_ads_client = GoogleAdsClient(login_customer_id=self.login_customer_id, credentials=credentials,
developer_token=self.developer_token)
self.ga_service = self.google_ads_client.get_service("GoogleAdsService", version="v9")
self.ga_service.search_stream(customer_id =self.client_customer_id, query = self.query)
Which throws error:
ERROR:'Credentials' object has no attribute 'with_subject'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论