Authentication failed. Either supplied credentials are invalid or the account is inactive

NIKHIL KUMAR 126 Reputation points
2025-11-11T14:38:49.7533333+00:00

Hello All,

I have been working on Microsoft Ads API data ingestion and I would need a help to proceed ahead as I am stuck at one stage with an error.

Below are the steps I have already performed:

  1. Created azure app registration.
  2. Requested consent and approved using URL: https://login.microsoftonline.com/your_tenant_id/oauth2/v2.0/authorize?client_id=your_client_id&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F&response_mode=query&scope=openid%20offline_access%20https%3A%2F%2Fads.microsoft.com%2Fmsads.manage&state=12345
  3. Able to generate the auth code, access tokens and refresh tokens as well with
       SCOPE = "https://ads.microsoft.com/msads.manage"
    

However, post the same when I go ahead and execute the code i get below:

ERROR:

<AdApiError>

<Code>105</Code>

<Detail i:nil="true"/>

<ErrorCode>InvalidCredentials</ErrorCode>

<Message>Authentication failed. Either supplied credentials are invalid or the account is inactive</Message>

</AdApiError>

CODE BLOCK:

oauth = OAuthDesktopMobileAuthCodeGrant(

        client_id=CLIENT_ID,

        tenant = TENANT_ID,

        env = ENVIRONMENT

    )

oauth.request_oauth_tokens_by_refresh_token(REFRESH_TOKEN)

authorization_data = AuthorizationData(

developer_token=DEVELOPER_TOKEN,

account_id=ACCOUNT_ID,

customer_id=CUSTOMER_ID,

authentication=oauth

)

campaign_service = ServiceClient(

service='CampaignManagementService', 

version = 13,

authorization_data=authorization_data, 

environment = ENVIRONMENT,

)

get_campaigns_account = campaign_service.GetBrandKitsByAccountId(

AccountId=ACCOUNT_ID

)

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 - Vahid 110 Reputation points Microsoft External Staff Moderator
    2025-11-11T15:33:45.8266667+00:00

    Hello Nikhil,

    Thank you for using our Microsoft Advertising Learn Q&A Platform! 

    I understand that you have been grappling with API data ingestion and facing an error. I hope the response and resources provided here can be of some use to you.

    Our support teams are also 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! 

    The error you are encountering could be related to the way you are requesting the access tokens or handling the refresh token. Ensure that you are following the correct steps to redeem the refresh token for a new access token. According to the Microsoft Ads API documentation, when you refresh the access token, you must include the client_id, client_secret, grant_type set to refresh_token, and the refresh_token you received earlier. Additionally, you need to specify the scope and tenant parameters in your request. Make sure that the tenant is set to common if you want to support both MSA personal accounts and Azure AD work or school accounts. If you are still facing issues, refer to the Common OAuth errors guide for troubleshooting help.

    You can learn more here: Get access and refresh tokens

    I hope the information provided here will at least partly answer your question.  If you have any additional questions please do not hesitate to reach out to our support. I have also sent you a private message asking for further details. You are more than welcome to respond to me to that I can begin the investigation on my end.

     

    Kind regards, 

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

    0 comments No comments

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.