Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Authentication to Dynamics 365 using Azure Apps

Posted on by 5
I was trying to obtain JWT token from Microsoft Azure Active Directory using  Certificate credentials for application authentication

Since There are two ways to create the app

1) App Registrations(Legacy)
2) App Registrations



After creating the app test-app-13 from any of the above two places, I uploaded the same public certificate file from two places below-:
1) AzureActiveDirectory-> AppRegistrations(Legacy) -> test-app-13->Settings->Keys->Upload public key

header = {
"alg": "RS256",
"typ": "JWT",
"x5t": "oO/ImH7U2wcypCvrY+iYalHOOmg="
};

When I am using "x5t": "oO/ImH7U2wcypCvrY+iYalHOOmg=" then authentication works.

2) AzureActiveDirectory-> AppRegistrations -> test-app-13-> Certificates & secrets -> Upload certificate

header = {
"alg": "RS256",
"typ": "JWT",
"x5t": "A0EFC8987ED4DB0732A42BEB63E8986A51CE3A68"
};
But when I am using "x5t": "A0EFC8987ED4DB0732A42BEB63E8986A51CE3A68" then I keep getting error

  {  
  "error":"invalid_client",
  "error_description":"AADSTS700027: Client assertion contains an invalid 
  signature. [Reason - The key was not found., Thumbprint of key used by 
  client: 
  '0341050BCF7CEC40F80C1D3BDF6038D81101EB713CF7CE80E75084DC0EBC', Please 
  visit 'https://developer.microsoft.com/en-us/graph/graph-explorer' 
  and query for 
  'https://graph.microsoft.com/beta/applications/2e452b20-df6d-4228- 
  83c6-5742b1a8f59c' to see configured keys]\r\nTrace ID: 0a77a624- 
  684d-4145-9ce5-d19e1b6ccb00\r\nCorrelation ID: 09254eb4-6128-4e18-a 
  bf6-70b5e9a68960\r\nTimestamp: 2019-05-09 12:39:29Z",
  "error_codes":[700027],
  "timestamp":"2019-05-09 12:39:29Z",
  "trace_id":"0a77a624-684d-4145-9ce5-d19e1b6ccb00",
  "correlation_id":"09254eb4-6128-4e18-abf6-70b5e9a68960"
  }


My question is why "x5t": "A0EFC8987ED4DB0732A42BEB63E8986A51CE3A68I" not working if uploading the public certificate from
path AzureActiveDirectory-> AppRegistrations -> test-app-13->Settings-> Certificates & secrets -> Upload certificate and
why the value of customKeyIdentifier is generated differently from these two places?

 

*This post is locked for comments

  • Sebra Profile Picture
    Sebra 10 on at
    RE: Authentication to Dynamics 365 using Azure Apps

    Hi Anand,

    thank you for your reply and the information. I have changed the code to encode the SHA-1 encoded certificate with Base64.

    Now, it works.

    Best regards

    Seb

  • anandkgpt03 Profile Picture
    anandkgpt03 5 on at
    RE: Authentication to Dynamics 365 using Azure Apps

    Hi Seb

    The new value you’re seeing for customKeyIdentifier is the thumbprint, just hex-encoded. If you take that value and convert it to base64, you should be able to authenticate with it.

    Hope it helps.

    Thanks

    Anand

  • Sebra Profile Picture
    Sebra 10 on at
    RE: Authentication to Dynamics 365 using Azure Apps

    Hi anandkgpt03,

    hope you are doing well. I just come cross your post. Actually, I spent ours to figure out, why I cannot authenticate by certificate to request a token.
    Everything looked fine.

    I am very happy, that I found your post. 

    Unfortunately, I can confirm the behavior you have described. The authentication won´t work with the Custom Key Identifier generated in the new "App registration" when upload the certificate there.

    Have found out a reason or did you leave it as is.

    Thanks in advance

    Seb

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans