Closed asrivastavsprighub closed 2 years ago
thanks for response. we already implemented MFA. 5 days ago it was working but now it throws error
What I see from log is UserError...Code=OAuthTokenInvalid. Target=. Message=Authenticaton token contains invalid scope; expected=ads.manage or msads.manage; actual=ads.manage; ... I think this is due to invalid scope you are using.
TrackingId: 86c39098-51a4-4ff9-9c23-9619457f0e10. for this tracking id i used scope msads.manage. but still getting same error
I see the same error. Could you please share your code piece?
oauth_token = OAuthTokens(access_token=@accesstoken, access_token_expires_in_seconds=3600, refresh_token=@refreshtoken)
authorization_data = AuthorizationData( developer_token='@developertoken', customer_id='@cid', account_id='@cid', #i tried with cid & aid both authentication=OAuthAuthorization(client_id=@clientid, oauth_tokens= oauth_token ), )
campaign_service = ServiceClient( service='CustomerManagementService', version = 13, authorization_data=authorization_data, environment = 'production', )
campaign_service.GetAccountsInfo(CustomerId=None,OnlyParentAccounts=False)
Thanks for sharing, I am most interested in how you get your accesstoken and refreshtoken. You need to give the the scope when you get refreshtoken first time right?
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=@clientid&scope=https://ads.microsoft.com/ads.manage offline_access&response_type=code&redirect_uri=https://sprighub.ai&state=ClientStateGoesHere this url return code
https://login.microsoftonline.com/common/oauth2/v2.0/token -ContentType application/x-www-form-urlencoded -Method POST -Body "client_secret=$clientsecret&client_id=$clientId&scope=https://ads.microsoft.com/msads.manage offline_access&code=$code&grant_type=authorization_code&redirect_uri=https://sprighub.ai
this is first time token generation process
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=@clientid&scope=https://ads.microsoft.com/msads.manage offline_access&response_type=code&redirect_uri=https://sprighub.ai&state=ClientStateGoesHere
so you mean you already use msads.manage right? I cannot tell anything wrong with this. Did you see 2FA during the process?
Yes i am using msads.manage. it asking opt only when i am trying to authenticate that's it
Server raised fault: 'Invalid client data. Check the SOAP fault details for more information. TrackingId: dd112067-7504-4d9b-a170-175dfaeb4b06.'
Please resolve this issue
@Ritik262 , from the log I see invalid customerid, this is user error. Please make sure the customer id passed in is correct.
*** suds.WebFault: Server raised fault: 'Invalid client data. Check the SOAP fault details for more information. TrackingId: 812a98df-6fad-494a-85c2-e78aa4ebf489.' bulk_file_path = bulk_service_manager.download_file(download_parameters) Please resolve this issue same issue again relase
import uuid from bingads.v13.bulk import * from suds import WebFault
from bingads.v13.bulk import DownloadParameters from source.utils.genric import creds_auth
FILE_DIRECTORY = 'variables' DOWNLOAD_FILE_NAME = "result.csv" UPLOAD_FILE_NAME = "upload.csv"
FILE_TYPE = 'Csv'
RESULT_FILE_NAME = 'result.csv'
################################### Bulk service manager helper ############################################### def write_entities_and_upload_file(bulk_service_manager, upload_entities): import pdb; pdb.set_trace()
# without writing to file. This example writes to file as an exercise so that you can view the structure
# of the bulk records being uploaded as needed.
writer = BulkFileWriter(FILE_DIRECTORY + UPLOAD_FILE_NAME)
for entity in upload_entities:
writer.write_entity(entity)
writer.close()
file_upload_parameters = FileUploadParameters(
result_file_directory=FILE_DIRECTORY,
compress_upload_file=True,
result_file_name=RESULT_FILE_NAME,
overwrite_result_file=True,
upload_file_path=FILE_DIRECTORY + UPLOAD_FILE_NAME,
rename_upload_file_to_match_request_id=False,
response_mode='ErrorsAndResults'
)
bulk_file_path = bulk_service_manager.upload_file(file_upload_parameters)
download_entities = []
entities_generator = read_entities_from_bulk_file(file_path=bulk_file_path, result_file_type=ResultFileType.upload,
file_type=FILE_TYPE)
for entity in entities_generator:
download_entities.append(entity)
return download_entities
def download_file(bulk_service_manager, download_parameters): import pdb;pdb.set_trace() bulk_file_path = bulk_service_manager.download_file(download_parameters=download_parameters,progress = None)
download_entities = []
entities_generator = read_entities_from_bulk_file(file_path=bulk_file_path,
result_file_type=ResultFileType.full_download,
file_type=FILE_TYPE)
for entity in entities_generator:
download_entities.append(entity)
return download_entities
def read_entities_from_bulk_file(file_path, result_file_type, file_type): with BulkFileReader(file_path=file_path, result_file_type=result_file_type, file_type=file_type) as reader: for entity in reader: yield entity
#######################################################################################################################
def append_digg_id(bulk_service_manager): try: import pdb;pdb.set_trace() download_parameters = DownloadParameters( download_entities=['Ads'], result_file_directory=FILE_DIRECTORY, result_file_name=DOWNLOAD_FILE_NAME, overwrite_result_file=True )
print("Downloading...")
download_entities = download_file(
bulk_service_manager=bulk_service_manager,
download_parameters=download_parameters)
upload_entities = []
for index, entity in enumerate(download_entities):
random_value = uuid.uuid4().hex
if isinstance(entity, BulkResponsiveSearchAd) or isinstance(entity, BulkResponsiveAd):
entity.ad.FinalUrlSuffix = f'DiggID={random_value}'
upload_entities.append(entity)
if len(upload_entities) > 0:
print(f"uploading... {len(upload_entities)} ads...")
download_entities = write_entities_and_upload_file(
bulk_service_manager=bulk_service_manager,
upload_entities=upload_entities)
except WebFault as ex:
print(ex)
except Exception as ex:
print(ex)
This code i am facing issue please resolve this
What I see from the log shows "The Account ID is invalid". Please make sure you are using correct accountId. You can find your account Id from web ui.
From: JonZ @.> Sent: Tuesday, April 18, 2023 11:45 PM To: BingAds/BingAds-Python-SDK @.> Cc: Qingjun Tian @.>; State change @.> Subject: Re: [BingAds/BingAds-Python-SDK] Server raised fault: Invalid client data. Check the SOAP fault details for more information (Issue #219)
Can I get some help as well: Invalid client data. Check the SOAP fault details for more information. TrackingId: 21311e40-cc5b-47ec-8e10-b3d3a28c1353.
- Reply to this email directly, view it on GitHubhttps://github.com/BingAds/BingAds-Python-SDK/issues/219#issuecomment-1513390427, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AG6WBQPINDTBYL42ZLUIFO3XB2ZIFANCNFSM56U4ALIQ. You are receiving this because you modified the open/close state.Message ID: @.**@.>>
Server raised fault: Invalid client data. Check the SOAP fault details for more information. TrackingId: ae2cf7a5-8ea4-4d15-99e6-89250223639e