question

MichaelVeloso-8632 avatar image
1 Vote"
MichaelVeloso-8632 asked EricUrban-MSFT answered

Authing into Microsoft Ads Java SDK from an automated process

I'm trying to get started using the Bing Ads Java SDK to manage the accounts we own using an automated process, but an having trouble with authing; the code examples provided here don't seem to fit that use case, in that they assume interaction with a user who will actively grant permission.

We already have OAuth credentials that other processes (in Ruby) use, and I'm hoping to use those for our Java (technically Kotlin) processes, but it's not clear which Authentication type to include in the AuthorizationData.

Currently, while experimenting, I've been using the OAuthDesktopMobileImplicitGrant, which allows me to instantiate a CustomerManagementService and make a successful GetCurrentUserRequest.

However, while I can instantiate a CampaignManagementService, I haven't been able to make a successful GetCampaignsByAccountIdRequest, even though I'm providing the same AccountId present in the AuthorizationData. Inspecting the SOAP response shows the error "An internal error has occurred.", though I'm guessing it's a problem with my implementation, and not something internal to your system.

Could you provide guidance? Am I using the correct Authentication type for my use case?



advertising-api
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

EricUrban-MSFT avatar image
0 Votes"
EricUrban-MSFT answered

For repeat or long term authentication, you should follow the authorization code grant flow (OAuthWebAuthCodeGrant or OAuthDesktopMobileAuthCodeGrant ) for obtaining an access token.

The internal error is likely unrelated. Please feel free to share the SOAP response with support and we're happy to help troubleshoot.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.