Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Issue with MFA authentication using ADAL Java

$
0
0

Hello community.

I have native application, have proper secret key.

Next one - I have JAVA application which properly obtain token, using appId and secret key.

But, when I tried to obtain the data using HTTPClient and token - I always have 401 error.

If need, I present code example below:

String accesToken = result.getAccessToken();

System.out.println(accesToken);

Header odataMaxVersion = new BasicHeader("OData-MaxVersion", "4.0");
Header odataVersion = new BasicHeader("OData-Version", "4.0");
Header headerContentType = new BasicHeader("Content-type", "application/json;IEEE754Compatible=true");

List<Header> headers = new ArrayList<>();

headers.add(odataMaxVersion);
headers.add(odataVersion);
headers.add(headerContentType);

HttpClientContext context = null;
Header headerAuthentication = new BasicHeader("Authorization", "Bearer " + accesToken);
headers.add(headerAuthentication);

HttpClient client = HttpClients.custom().setDefaultHeaders(headers).build();

HttpRequestBase request;
HttpResponse response = null;

String requestURLString = RESOURCE + "/api/data/v9.0/EntityDefinitions(LogicalName='invoice')/Attributes?$filter=IsValidForRead%20eq%20true";
request = new HttpGet(requestURLString);

response = client.execute(request, context);
int responseCode = response.getStatusLine().getStatusCode();

Finally, responseCode is 401.
May be I'm an idiot


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images