Azure / Microsoft365R

R SDK for interacting with Microsoft 365 APIs
Other
308 stars 41 forks source link

Attachment bigger then 3mb is broken #192

Closed robayo closed 5 months ago

robayo commented 8 months ago

Hey all, I use this library daily and it has been working perfectly for sending emails with attachments bigger than 3mb but today it stoped working. Nothing has changed but R now throws this error: Error in make_large_attachment(object, self) : Unauthorized (HTTP 401).

When debugging the URL that is sent I get this error: {"error":{"code":"InvalidAudienceForResource","message":"The audience claim value is invalid for current resource. Audience claim is 'https://outlook.office.com/api/', request url is 'https://outlook.office365.com' and resource type is 'Exchange'.","innerError":{"oAuthEventOperationId":"f6eb9336-3285-4258-b8ed-fa195ff2fbdd","oAuthEventcV":"E2tF021AVOB25M0eERD1Pw.1.1","errorUrl":"https://aka.ms/autherrors#error-InvalidResource","requestId":"d3456b13-406d-e054-76e4-cd1e1110f53f","date":"2023-11-29T22:26:42"}}}

I don't know if the API is now fully deprecated for Outlook. Is there a timeline for migrating fully to the Graph API in Outlook?

apalacio9502 commented 8 months ago

Hello,

The same thing is happening to us. I'm not sure if there is a temporary solution to this issue.

Regards,

apalacio9502 commented 8 months ago

Hello,

I think the error is related to the fact that the dev version does not support "Create session to attach large file", however, reading the AzureGraph API Beta documentation it does not say that files larger than 3 megabytes cannot be sent by "Add attachment to a message", I tested and was able to send 20 Mb without problem.

I think it would be important to validate what step to follow with the attachments because reading the documentation the "Create session to attach large file" is already deprecated and will be eliminated at the beginning of next year

Regards,

hongooi73 commented 8 months ago

Microsoft365R doesn't use the old Outlook API at all, it's purely Graph. This might just be a glitch on the MS side. If possible, wait a day or two and try again.

hongooi73 commented 8 months ago

@apalacio9502 I don't see any indication that it's deprecated. Is this what you're looking at?

https://learn.microsoft.com/en-us/graph/api/attachment-createuploadsession?view=graph-rest-beta&tabs=http

apalacio9502 commented 8 months ago

@apalacio9502 I don't see any indication that it's deprecated. Is this what you're looking at?

https://learn.microsoft.com/en-us/graph/api/attachment-createuploadsession?view=graph-rest-beta&tabs=http

Sorry, I was seeing the wrong documentation. You are right, the current documentation does not say that it is going to be decommissioned.

However, this announcement leaves me a little confused:

"As announced on November 17, 2020, version 2.0 of the Outlook REST API has been deprecated. The v2.0 REST endpoint will be fully decommissioned in November 2022, and the v2.0 documentation will be removed shortly afterwards. Migrate existing apps to use Microsoft Graph. See a comparison to start your migration."

Because the uploadsession uses the https://outlook.office.com/api in the PUT process, which I understand is the endpoint that is going to be decommissioned.

apalacio9502 commented 8 months ago

Microsoft365R doesn't use the old Outlook API at all, it's purely Graph. This might just be a glitch on the MS side. If possible, wait a day or two and try again.

I thought it was a glitch on the MS side, however I tested using the same user in python with the library https://github.com/vgrem/Office365-REST-Python-Client, and it did not generate an error, reading the documentation I understand that it uses the same technology.

On the other hand, I am sure that it is not a problem related to the libraries called by Microsoft365, since I carried out tests in an environment in which the R libraries have not been updated since June and until Monday the sending of emails with attachments worked correctly.

apalacio9502 commented 8 months ago

Debugging the function, I see the same error that happens to @robayo

{\"error\":{\"code\":\"InvalidAudienceForResource\",\"message\":\"The audience claim value is invalid for current resource. Audience claim is 'https://outlook.office.com/api/', request url is 'https://outlook.office365.com' and resource type is 'Exchange'.\",\"innerError\":{ \"oAuthEventOperationId\":\"0434247c-8b96-4129-bf90-21b826a8efdc\",\"oAuthEventcV\":\"i0Ei/IV5FGlUavv756n8TA.1.1\",\"errorUrl\":\"https://aka. ms/autherrors#error-InvalidResource\",\"requestId\":\"fc22418b-7985-6914-546a-fbfbe7a9fc4c\",\"date\":\"2023-12-01T04:51:20\"} }}

hongooi73 commented 7 months ago

The R code only uses the Graph API, including any attachment-related calls. However, under the hood the Graph API might call the Outlook API, which is what causes this error.

So, it looks like there's a new tasks API that replaces Outlook. I'll see what I can do.

apalacio9502 commented 7 months ago

Thank you for your prompt response, we are awaiting any progress or aspect in which we can support, given that this library has become essential for us on a daily basis.

hongooi73 commented 7 months ago

I'm testing this now, and I don't get any errors or warning messages. @apalacio9502 @robayo are you still seeing the error?

robayo commented 7 months ago

The problem seems fixed by Microsoft for now. Nevertheless I hope that on March 2024, when the Outlook API is fully deprecated, the returned uploadUrl is changed to a Graph API endpoint automatically. We have to keep checking that.

hongooi73 commented 7 months ago

I think this was just a momentary glitch in the matrix.

There's no indication that the Graph API endpoint to create large attachments is deprecated. The fact that the returned uploadUrl points to "outlook.office.com" shouldn't matter, since it isn't a user-visible URL: it's all handled by the code. Regardless, I've asked for clarification on this.

hongooi73 commented 5 months ago

Closing as this appears to have been a temporary backend thing