Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Authenticate twice for Web API and Organization URL - Using REST ?

Posted on by 5

I'm trying to read customer data from any user who has dynamics CRM account.

First step, I'm using the below url to get the access token for retrieving the organization url for the user. It shows the consent and asks for credentials. Response will have the organization url.

login.microsoftonline.com/.../authorize`+
Second step, to retrieve the data, it is advised to use the organization url and authorize as below.
`login.microsoftonline.com/.../authorize`+
`?resource=`+<organization from first step> 
It would give the access token needed to retrieve the data.
My question is, it is prompting for user authentication twice, in both steps. Is it possible to let the second step use the same credentials as the first one. 
Thanks for your help in advance,
Sreelatha
  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Authenticate twice for Web API and Organization URL - Using REST ?

    Hi,

    Yes it is possible to interact with CRM web api using access token which you have obtained from first step without user interaction and they will not have to enter their credentials again.

    Pass Access Token in header as Bearer.

    var myHeaders = new Headers();
    myHeaders.append("Accept", "application/json");
    myHeaders.append("Content-Type", "application/json; charset=utf-8");
    myHeaders.append("Prefer", "odata.maxpagesize=2");
    myHeaders.append("Prefer", "odata.include-annotations=\"*\"");
    myHeaders.append("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IllNRUxIVDBndmIwbXhvU0RvWWZvbWpxZmpZVSIsImtpZCI6IllNRUxIVDBndmIwbXhvU0RvWWZvbWpxZmpZVSJ9.eyJhdWQiOiJodHRwczovL21tZGV2LmNybS5keW5hbWljcy5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8wOTVmMDk3Ni1iZjY2LTRkNzYtYmYyOS0wZmJhYjA4ODRlY2IvIiwiaWF0IjoxNTg2MDA4NTc1LCJuYmYiOjE1ODYwMDg1NzUsImV4cCI6MTU4NjAxMjQ3NSwiYWlvIjoiNDJkZ1lMRFZ1Sk1UcEhqY2I4ZU8yb3ViYzZkK0FnQT0iLCJhcHBpZCI6ImRiYmZlZDAzLTUwMjMtNDEwYi1iNTg4LThkYjcwYTYxYzhhZiIsImFwcGlkYWNyIjoiMSIsImlkcCI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0LzA5NWYwOTc2LWJmNjYtNGQ3Ni1iZjI5LTBmYmFiMDg4NGVjYi8iLCJvaWQiOiI2MTgyMTgzOS0xZWUwLTQwOGUtOTk3ZC1mYjE1OGY0Yzk2ODYiLCJzdWIiOiI2MTgyMTgzOS0xZWUwLTQwOGUtOTk3ZC1mYjE1OGY0Yzk2ODYiLCJ0aWQiOiIwOTVmMDk3Ni1iZjY2LTRkNzYtYmYyOS0wZmJhYjA4ODRlY2IiLCJ1dGkiOiIzd0ZneGl1VWpFYS1BdmJ1TW1NT0FBIiwidmVyIjoiMS4wIn0.S4Ao6bX9WkdIUMNcLNFyCxq3hF1jx8J_4gS4izO9jOpPzFuynyq8j3pPeqBc_6Dh-IzLu5OFIH2agol6rmZ1rlLEDi5zXQKwYvTKkKUgQZQlRLzWaIIYtQIYOReYwj6NEjfOQb6tufqGYdAVsIlJVcVqWHkfrSbsyQdoUZBObE3t-9vGUVYM-p0mFUEUYoiNzr-wKLtXrsc14Zt5aclvQmnQrt-4JVZnjOt5mSGj7PWZl5gdhLkXPYoRQhcBsMC777aqVr3o5EaZTmUJh482eQjDOMj8pGq3wipQPOZ1UKOkc6QBHqI78rObmzT-mrRP73yqNcdIe9H8jNdPgPGnyQ");

    If found helpful, Please mark my answer verified.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans