No outlook webhook notification for events in secondary calendars - outlook

I have successfully subscribed to changes of the events resource with a request body of:
{
"#odata.type": "#Microsoft.OutlookServices.PushSubscription",
"Resource": "me/events",
"NotificationURL": "...",
"ChangeType": "Created, Updated, Deleted"
}
Although I get the expected webhook notification when modifying an event in the user's default calendar, I don't get any webhook notifications when modifying events in other calendars of the same user.
Am I doing something wrong or is it a bug or just an undocumented behaviour?

To subscribe the notification of other calendars, you need to change the the "Resource" to "me/calendars/{calendar_id}/events".
GET https://outlook.office.com/api/v2.0/me/calendars
{
"#odata.type": "#Microsoft.OutlookServices.PushSubscription",
"Resource": "me/calendars/{calendar_id}/events",
"NotificationURL": "...",
"ChangeType": "Created, Updated, Deleted"
}

Related

Microsoft Teams HttpPost Action print http return status

We want to know what is the best way to do :
an alert is sent to the MS teams channel, the alert contains "Approve" and "Deny"
Both "Approve" or "Deny" has "HttpPost" to send the POST to target URL
After clicking "Approve" or "Deny", how do we get the http status and print the comment "Approved" if http status is "200" ?
After clicking either approve or deny, how do we print the comment with whoever clicked(for example logged in user) so that others will know.
This is below payload :
{
"#type":"MessageCard",
"#context":"http://schema.org/extensions",
"themeColor":"0076D7",
"text":"### Build [($BUILD_NUMBER)]($CONSOLE_LINK) of [($BUILD_LINK)]($BUILD_URL) failed on [($BM_NAME)]($JENKINS_URL)",
"potentialAction":[
{
"#type":"HttpPost",
"name":"Approve",
"body": "verification.approve",
"target":"https://learn.microsoft.com/outlook/actionable-messages"
},
{
"#type": "OpenUri",
"name": "Deny",
"targets": [{
"os": "default",
"uri": "https://learn.microsoft.com/outlook/actionable-messages"
}]
}
],
}
You need to implement a Bot or Client App and then while calling the Webhook Http/Https URL, you need to capture the response & based on response code, you can take action accordingly.

Unable to delete a message sent via Incoming Webhooks

I am using Slack Incoming Webhooks requests to post messages to a Slack channel from an app. I love it since I can send messages directly from shell scripts.
However going further I stumble into the problem that I seem to be unable to delete messages.
The app has two access tokens:
An OAuth access token xoxp-012345678901-012345678901-012345678901-0123456789abcdef0123456789abcdef (this is a fictitious token but the length is the same as the actual token).
Bot User OAuth access token xoxb-012345678901-012345678901-0123456789abcdef01234567.
Using the xoxp- OAuth access token I can retrieve channel history.
curl "https://slack.com/api/channels.history?token=xoxp-012345678901-012345678901-012345678901-0123456789abcdef0123456789abcdef&channel=CABCDABCD&count=20&pretty=1"
With the xoxb- token the channels.history request fails with
{
"ok": false,
"error": "not_in_channel"
}
In chat history I have a message that I would like to delete. The message was posted using Incoming Webhooks associated with the App.
{
"type": "message",
"subtype": "bot_message",
"text": ":heavy_check_mark:",
"ts": "1580968882.000800",
"bot_id": "BABCDABCD",
"blocks": [
{
"type": "section",
"block_id": "5Ov",
"text": {
"type": "mrkdwn",
"text": "text of the message to delete",
"verbatim": false
}
}
]
}
However neither token works with chat.delete. Both
curl "https://slack.com/api/chat.delete?token=xoxb-012345678901-012345678901-0123456789abcdef01234567&channel=CABCDABCD&ts=1580968882.000800&pretty=1"
and
curl "https://slack.com/api/chat.delete?token=xoxp-012345678901-012345678901-012345678901-0123456789abcdef0123456789abcdef&channel=CABCDABCD&ts=1580968882.000800&pretty=1"
fail with
{
"ok": false,
"error": "cant_delete_message"
}
And the question is: Is there a way to delete a message posted by an app via Incoming Webhooks requests?
PS. Both chat:write:bot and chat:write:user permissions are granted.
Yes, but the token owner needs to be admin in order to have the right to delete message of other users / apps.
To clarify: This has nothing to do with OAuth scopes, but with the Slack role of the user who owns the token.

How to send a proactive message from a bot to a user

I am trying to send a message from a bot to a teams user who hasn't already installed the bot and doesn't need to install the bot via REST API.
I have tried following this document.
It clearly states:
"Sending a message to start a new conversation thread is different than sending a message in response to an existing conversation: when your bot starts a new a conversation, there is no pre-existing conversation to post the message to. In order to send a proactive message you need to:"
As far as I understand, this means that what I am trying to do is possible. I have tried to run this sample.
However, as far as I can tell it needs a conversation id. Without a conversation id it doesn't work.
I have tried to send a request like this with a bot network token ( which is normally used to respond to an activity request by the user):
POST /v3/conversations
{
"bot": {
"id": "28:10j12ou0d812-2o1098-c1mjojzldxcj-1098028n ",
"name": "The Bot"
},
"members": [
{
"id": "29:012d20j1cjo20211"
}
],
"channelData": {
"tenant": {
"id": "197231joe-1209j01821-012kdjoj"
}
}
}
However, it fails with the following message:
Send Message to https://graph.microsoft.com/v3/conversations failed: (401) {
"error": {
"code": "InvalidAuthenticationToken",
"message": "Access token validation failure. Invalid audience.",
"innerError": {
"request-id": "92922235-8c87-47ed-92bc-4ba17469611a",
"date": "2019-09-24T14:43:59"
}
}
}
I am guessing that this maybe because I didn't send MicrosoftAppCredentials.TrustServiceUrl first. But this is a c# call. How do I make the same call in REST API?
Please take a look at Bot Framework REST APIs documentation.
Here are steps to generate the access token which you could use to call Create Conversation APIs.
POST https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&client_id=MICROSOFT-APP-ID&client_secret=MICROSOFT-APP-PASSWORD&scope=https%3A%2F%2Fapi.botframework.com%2F.default

Outlook REST API - Send As

I am currently using the Outlook REST API to send email. This is working fine when sending from a user mailbox such as:
https://outlook.office.com/api/v2.0/users/user#domain.com/sendMail
'user#domain.com' is the UPN of a valid user account in Azure AD.
What I need to do is 'send as' a shared mailbox. According to the documentation this can be achieved by changing the 'From' property in the JSON request body. An example would be:
{
"Message": {
"Subject": "Email Unit Test",
"Body": {
"ContentType": "HTML",
"Content": "Message body"
},
"ToRecipients": [
{
"EmailAddress": {
"Address": "recipient#somehost.com"
}
}
],
"Attachments": [
],
"From": {
"EmailAddress": {
"Address": "shared_mailbox#domain.com"
}
},
"Sender": {
"EmailAddress": {
"Address": "user#domain.com"
}
}
},
"SaveToSentItems": "false"
}
Now, when I give user#domain.com 'Send As' and 'Send On Behalf Of' access to the shared mailbox this works. The recipient gets an email with the from field saying 'user#domain.com On Behalf Of shared_mailbox#domain.com'. What I want however is for the email to appear as being sent from shared_mailbox only without the on behalf of user. To test this out further I removed the 'Send On Behalf Of' access and left 'Send As' access only. In the API I now get an error:
{
"error": {
"code": "ErrorSendAsDenied",
"message": "The user account which was used to submit this request does not have the right to send mail on behalf of the specified sending account., Cannot submit message."
}
}
Interestingly though, in my Outlook client I can still send an email from the shared mailbox and it works as expected with no 'on behalf of' in the From field. I'm starting to wonder whether this is a limitation of the REST API however there is nothing in the Microsoft docs to suggest this.
Has anyone had similar experiences with the REST API?
I tried to do the same thing and it seems the REST API allows you to implement "send on behalf of" but not "send as" feature.

Google Calendar Events Response is Empty

We are fetching google calendar events through OAuth2 tokens with Google Calendar API V3 to our customers, but for some of customers' calendar getting empty response. We got empty response for the same calendar in Google OAuth Playground.
{
"nextPageToken": "CjkKK2xwamMycHJ2MDU2cGp2YFxcmY3OXRtNTg0XzIwMTQwMjEyVDA0MzAwMFoYASCAgMDEtcaFoBQaDQgAEgAY2M-X7qfLvAI=",
"kind": "calendar#events",
"defaultReminders": [
{
"minutes": 30,
"method": "popup"
}
],
"items": [],
"updated": "2014-02-14T09:32:57.943Z",
"summary": "TEST",
"etag": "\"TuPKiPtcUnaxp3U8BefUMu26Bg/LWnnxrAP6L1-mgjBDhy0rIebYaE\"",
"timeZone": "Asia/Calcutta",
"accessRole": "owner"
}
But when the same user is authenticated through AuthSub, it is fetching the events list. Is anyone having the same issue? Any help would be appreciated.
TIA,
Riyaz.A
Have you tried actually calling the API with the nextPageToken? Usually the client libraries do this auto pagination for you, but in this case you may need to manually make the call. In general, you should plan on calling next pages until nextPageToken is empty or not present.
This might just be an weirdness with the API.
We can't set pageToken to the event instance
Calendar.Events.List events = service.build().events().list(gCalId);
But when we try model Events instance, we able to set pageToken and got response too
com.google.api.services.calendar.model.Events events = service.build().events().list(gCalId).setPageToken(pageToken).execute();

Resources