After executing the above code by replacing the values for ClientID,ClientSecret and TenantId, I am seeing the below error :
Message: The remote server returned an error: (400) Bad Request.
Status: ProtocolError.
I have also tried using the authority uri as https://login.microsoftonline.com/<TenantID>/oauth2/token but still the same error.
I really appreciate your response why I am seeing this bad request error.