getting the error of "Invalid_client" for get the token when grant_type is "authorization_code"

Parshva Doshi 1 Reputation point
2022-08-12T17:13:39.56+00:00

I used the below API for sending the message in the channel with the body in application/Json format
POST : https://graph.microsoft.com/beta/teams/{{team_id}}/channels/{{channel_id}}/messages

I need a bearer token for the above API so I used the below API to get the token
POST: https://login.microsoftonline.com/{{tenant_id}}/oauth2/v2.0/token
Body: client_id : {{client_id}}
client_secret : {{client_secret}}
scope: ChannelMessage.Send
grant_type : authorization_code
redirect_uri : http://localhost/myapp/
code : {{code}}

but I got the error :

{  
    "error": "invalid_client",  
    "error_description": "AADSTS7000215: Invalid client secret provided. Ensure the secret being sent in the request is the client secret value, not the client secret ID, for a secret added to app '6731de76-14a6-49ae-97bc-6eba6914391e'.\r\nTrace ID: 92b7334e-a29a-4694-b00a-9fddc0496e00\r\nTimestamp: 2022-08-12 15:53:57Z",  
    "error_codes": [  
        7000215  
    ],  
    "timestamp": "2022-08-12 15:53:57Z",  
    "trace_id": "92b7334e-a29a-4694-b00a-9fddc0496e00",  
    "correlation_id": "e8f3f01a-73e6-458d-b669-c4fa8a8630ba",  
    "error_uri": "https://login.microsoftonline.com/error?code=7000215"  
}  

I put the client_secret value instead of secret id,
230760-photo.png
still it gives me this error.

So can anyone help me to find the solution?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,858 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 37,786 Reputation points
    2022-08-15T07:11:12.36+00:00

    Hi @Parshva Doshi

    First make sure your client secret has not expired.

    If your client secret was just created then don't use it right away, it will take effect with some delay. You can wait 1 minute and try again or run the request a few more times.

    If the above suggestions do not resolve the issue, you can try creating a new client secret instead.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.