Skip to content

Fixes for use with Microsoft Graph#979

Closed
plutext wants to merge 1 commit intoscribejava:masterfrom
plutext:master
Closed

Fixes for use with Microsoft Graph#979
plutext wants to merge 1 commit intoscribejava:masterfrom
plutext:master

Conversation

@plutext
Copy link

@plutext plutext commented Aug 21, 2020

With these changes, it is possible to use Microsoft Graph to upload/convert/delete a file, following https://medium.com/medialesson/convert-files-to-pdf-using-microsoft-graph-azure-functions-20bc84d2adc4

getAccessTokenEndpoint = MSFT_LOGIN_URL + tenant + OAUTH_2 + getEndpointVersionPath() + "/token";

For it to work for me, I have to have an empty EndpointVersionPath.

It is also necessary to pass a resource, to get the audience claim correct. I have hard coded this, but if you process this PR, you'll want to handle this differently.

@plutext
Copy link
Author

plutext commented Aug 22, 2020

A quote from the Microsoft documentation at https://docs.microsoft.com/en-us/graph/auth-v2-service#endpoint-considerations

Microsoft continues to support the Azure AD endpoint. There are several differences
between using the Microsoft identity platform endpoint
and the Azure AD endpoint.

When using the Azure AD endpoint, the parameters in authorization and token requests are different.

For example, there is no scope parameter in Azure AD endpoint requests;
instead, the resource parameter is used to specify the URI of the resource
(resource=https://graph.microsoft.com) that authorization (for administrator consent) or a token is being requested for.

So in this PR I'm evidently using the Azure AD endpoint

}

private static void addBody(HttpURLConnection connection, byte[] content, boolean requiresBody) throws IOException {
if (!requiresBody && content==null) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you show when can content be null?

@kullfar
Copy link
Member

kullfar commented Jan 19, 2021

It seems, that MicrosoftAzureActiveDirectoryApi.java - is what you need.

@kullfar kullfar closed this Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants