MicrosoftDocs / Advertising-docs

Creative Commons Attribution 4.0 International
15 stars 59 forks source link

How to use Sandbox in an environment like Jenkins #1024

Closed pacohh closed 3 years ago

pacohh commented 3 years ago

We are using the Sandbox environment to get a refresh token and run our tests. It all works fine when running the tests on the same machine where we got the refresh token, but once we try to run the tests on another machine it fails with the error:

AADSTS70000: The user could not be authenticated or user interaction is required. The user must sign in again and if needed grant the client application access to the requested scope.

I understand that this is because the application provided by Microsoft for the Sandbox environment only allows native clients[0] (no web applications) and therefore the refresh token is only valid for the machine where it was requested from[1].

What should we do to be able to run our tests on the Sandbox environment from different machines? Can we create our own web application in the Sandbox environment?


[0] https://docs.microsoft.com/en-us/advertising/guides/sandbox?view=bingads-13#access

The "Tutorial Sample App" client ID is limited to desktop or console applications, and cannot be used with any client secret in a web application.

[1] https://docs.microsoft.com/en-us/advertising/guides/authentication-oauth-get-tokens?view=bingads-13#refresh-accesstoken

Please keep in mind that public refresh tokens are only bound to the granted device. For example if you registered a Native app and use https://login.microsoftonline.com/common/oauth2/nativeclient as the redirect URI, we only guarantee that it can be refreshed on the same device. Clients running apps on services that span regions and devices such as Microsoft Azure should register a Web app with client secret.

eric-urban commented 3 years ago

@pacohh - Sorry it isn't on our roadmap to support registration of web applications in sandbox.