Microsoft Advertising API Error

Oscar harry 0 Reputation points
2025-10-28T12:40:08.06+00:00

HTTP Response

HTTP/1.1 401 Unauthorized

Cache-Control: no-cache

Pragma: no-cache

Content-Type: application/json; charset=utf-8

Expires: -1

Date: Tue, 28 Oct 2025 14:42:00 GMT

Content-Length: 456

Request-Id: 5fbc7a22-a1d3-47c9-b91a-18664507092

Client-Request-Id: 186<removed PII>

Response Body

{

"error": {

"code": "AuthenticationError",

"message": "Authentication failed. The provided access token is invalid or has expired.",

"target": "AuthorizationHeader",

"innerError": {

  "date": "2025-10-28T14:42:00Z",

  "request-id": "5fbc7a22-a1d3-47c9-b91a-18664507092",

  "client-request-id": "186<***removed PII***>"  
   client-request-id":  186<***removed PII***>  
    client-request-id":  +186<***removed PII***>

},

"details": [

  {

    "code": "InvalidCredentials",

    "message": "Access token signature is invalid. Please ensure you are using a valid OAuth 2.0 token."

  },

  {

    "code": "TokenExpired",

    "message": "The access token expired at 2025-10-28T13:30:00Z. Acquire a new token from Microsoft Identity Platform."

  },

  {

    "code": "AuthPolicyViolation",

    "message": "Your client application is not authorized for the requested resource scope."

  }

]
```  },

  "trackingId": "186<***removed PII***>",

  "correlationId": "a3cb<***removed PII***>",

  "timestamp": "2025-10-28T14:42:00Z"

}

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.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MS Advertising - Dagmara 395 Reputation points Microsoft External Staff Moderator
    2025-10-28T13:15:11.43+00:00

    Hi Oscar harry,

    Thank you for reaching out to the Microsoft Advertising Learn Q&A Platform!

    The error message you're receiving "HTTP/1.1 401 Unauthorized" indicates that the API request to Microsoft Ads failed due to authentication issues. Here's a breakdown of what it means and how to resolve it.

    • AuthenticationError: The request was rejected because the access token provided is either invalid or expired.
    • InvalidCredentials: The token's signature is not valid. This could mean it's malformed, tampered with, or not issued correctly.
    • TokenExpired: The token expired at 2025-10-28T13:30:00Z, so it’s no longer usable.
    • AuthPolicyViolation: The client application is not authorized to access the requested resource scope. This could be due to missing permissions or incorrect configuration.

    Here are the recommended steps to fix it:

    1. Acquire a New Access Token
    • Use Microsoft Identity Platform to request a fresh OAuth 2.0 token.
    1. Verify Token Signature
    • Make sure the token is generated correctly and hasn’t been altered.
      • Use a trusted library or SDK to handle token generation and signing.
    1. Check App Permissions
    • Confirm that the client application is registered in Azure AD and has the necessary API permissions.
      • If using delegated permissions, ensure the user has granted consent.
    1. Update Authorization Header
    • Include the new token in the Authorization header as:

    Code Authorization: Bearer <access_token>

    If the issue persists after refreshing the token and verifying permissions, it may help to review the app registration settings in Azure.

    Authentication with OAuth

    I hope the information provided here will at least partly answer your question. For us to make sure that we are able to address the issue, I'll be sending a private message on your inbox, please check your private message for further assistance.

    Our support teams are happy to discuss your account in more detail via phone, chat or email to provide review assistance, please see our support page to reach out!

    Kind regards, 

    Dagmara | Microsoft Advertising Support Specialist | 800-518-5689 


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.