Personalized Community is here!
Quickly customize your community to find the content you seek.
Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2020 Release Wave 2Discover the latest updates and new features to Dynamics 365 planned through March 2021.
Release overview guides and videos Release Plan | Preview 2020 Release Wave 2 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
I'm writing a simple android app in Java and recently implemented retrieving a token for a user (created a connected app in Azure, got app id etc.).
Trying to use the token with REST API and getting 401 error.
Read all the related answers here, nothing helped. The code I'm using:
//retrieved the authorization code by this url:
mAuthorizationUrl = Configuration.AUTHORIZE_ENDPOINT + "?response_type=code&client_id=" + Configuration.CLIENT_ID + "&redirect_uri=" + Configuration.REDIRECT_URI;
String body_content = "grant_type=authorization_code&client_id=" + Configuration.CLIENT_ID + "&" +
"redirect_uri=" + Configuration.REDIRECT_URI + "&" +
"code=" + code + "&resource=" + Configuration.CLIENT_ID;
//I don't have app URI (resource) in Azure, so I used app id (client id). This worked (see above).
RequestBody body = RequestBody.create(MediaType.parse("application/x-www-form-urlencoded; charset=utf-8"), body_content);
Request request = new Request.Builder().url(Configuration.TOKEN_RETRIEVAL_ENDPOINT).post(body).build();
Response response = new OkHttpClient().newCall(request).execute();
String responseString = response.body().string();
JSONObject json = new JSONObject(responseString);
String token = json.getString("access_token");
//NOT WORKING CODE:
OkHttpClient okHttpClient = new OkHttpClient().newBuilder().protocols(Collections.singletonList(Protocol.HTTP_1_1)).build();
Map<String, String> headers = new ArrayMap<>();
headers.put("Authorization", "Bearer " + token));
request = new Request.Builder().url(Configuration.REST_ENDPOINT).headers(Headers.of(headers)).build();
response = new OkHttpClient().newCall(request).execute();
statusCode = response.code();
Endpoints I used:
AUTHORIZE_ENDPOINT = "login.microsoftonline.com/.../authorize";TOKEN_RETRIEVAL_ENDPOINT = "login.microsoftonline.com/.../token";REST_ENDPOINT = "<url_to_crm>/api/data/v9.0/";
Business Applications communities