Authing into Microsoft Ads Java SDK from an automated process

Michael Veloso 6 Reputation points
2021-10-13T13:42:59.11+00:00

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?

Microsoft Advertising API
Microsoft Advertising API
A Microsoft API that provides programmatic access to Microsoft Advertising to manage large campaigns or to integrate your marketing with other in-house systems.
382 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Eric Urban - MSFT 626 Reputation points Microsoft Employee
    2021-10-24T13:56:42.067+00:00

    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.

    0 comments No comments