Reputation: 41
Our application stopped authorize new users to connect to Bing Ads this month. We tried to debug, and learning that we need to upgrade to the Microsoft identity platform endpoint. Our legacy application uses login.live.com and we are consistently getting errors "The remote server returned an error: (400) Bad Request."
We registered a new application in portal.azure.com, run the Quick Start from powershell and successfully retrieved a refresh token using the testing native application. As a next step, we
created a new application with a new clientID in portal.azure.com. Assigned the Authentication Type as Web instead of Native, and used our application redirect URI
In the Quick Start testing file Get-Tokens-Production.ps1, we replaced the clientID and redirectURI, and added the clientsecret variable
Ran the Quick Start powershell script using the new values
... and now we are consistently getting this message that says "The code has expired". I'm copying the code=parameter from the browser into the console just like we were doing with the native app testing, taking me maybe 15 seconds to copy and paste. Can someone help explain how we can test and get a valid refresh token?
Invoke-WebRequest : {"error":"invalid_grant","error_description":"AADSTS70000: The provided value for the 'code' parameter is not valid. The code has expired.\r\nTrace ID: 348801cc-9dce-4147-aded-d52910f93000\r\nCorrelation ID: 2438635c-7cd6-4a3f-9cdf-d3206db0409b\r\nTimestamp: 2019-12-04 19:47:05Z","error_codes":[70000],"timestamp":"2019-12-04 19:47:05Z","trace_id":"348801cc-9dce-4147-aded-d52910f93000","correlation_id":"2438635c-7cd6-4a3f-9cdf-d3206db0409b","e rror_uri":"https://login.microsoftonline.com/error?code=70000"}
Upvotes: 2
Views: 3748
Reputation: 9549
When you get the authorization code in the browser, its life cycle is actually very short, only about 10 minutes, and the authorization code can only be used once! When you try to obtain an access token or refresh token again, you must request a new authorization code from the browser again.
If you want to get a refresh token, then you need to add offline_access
to the scope
.
Upvotes: 1