web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Modern App Logon

(0) ShareShare
ReportReport
Posted on by

Has anyone gotten the Method DiscoverAuthority from the following sample to work with ADFS?

I keep getting this error: Invalid authenticate header format

I presume is because the response.headers["WWW-Authenticate"] contains ",Negotiate,NTLM" and thus the cast Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationParameters. CreateFromResponseAuthenticateHeader((response.Headers)["WWW-Authenticate"]); returns null

I got it to work by hardocding the oauth URL to https://[adfsurl]/adfs/ls instead of https://<serverFQDNaddress>/adfs/ls/XRMServices/2011/Organization.svc/web as the sample explains.

any insights would be great.

Thanks

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Forgot the link to the sample

    msdn.microsoft.com/.../dn481599.aspx

  • Jim Daly Profile Picture
    on at

    "..the following sample.." Which one are you referring to? This one msdn.microsoft.com/.../dn481599.aspx ?

  • Verified answer
    Community Member Profile Picture
    on at

    Fernando;

    The sample is quite old and needs to be updated. For example, it uses the preview ADAL NuGet package instead of the latest. There have been some ADAL API changes in the latest packages so the sample update is not simply to install the latest package. I have added the update as an action item for me.

    The OAuth URL is wrong in the SDK topic and will be fixed in the next release.

    Try this one liner instead of calling the DiscoverAuthority method:

    AuthenticationParameters parameters = await AuthenticationParameters.CreateFromResourceUrlAsync(serviceUrl);

    string _oauthUrl = parameters.Authority;

    Let me know if this works for you.

    Peter Hecke | Microsoft CRM SDK team

  • Community Member Profile Picture
    on at

    Peter,

    I changed my code to use the sample you provided below and it worked for a while running my code from the VS debugger and now if only works when I run the app deployed on tablets if I run it from VS I get the following error

    Unauthorized Http Status Code (401) was expected in the response

    I tried uninstalling and reinstalling ADFS. Repairing CRM and I still get that error any ideas?

  • Community Member Profile Picture
    on at

    If anyone has this issue make sure that the capabilities of the app are internetclient and that the enable loopback is set on the debugger.

  • Community Member Profile Picture
    on at

    Unfortunately, I have not seen this happen. When you try to call a web method, if the correct access token in the Authorization header is not supplied, you will get a 401 response, which is expected. From that response you parse the Authority URL. This is the normal flow. Make sure you are adding the SdkClientVersion parameter to your request URL. See msdn.microsoft.com/.../dn531009.aspx.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans