How to use the Slack API to subscribe to a thread? - slack-api

I'm playing with the Slack API and my goal is to replicate the "Follow Message" functionality provided in the slack web/desktop/mobile clients as shown in the screenshot below. I haven't found the right end point or permissions to make this work. Looking at the web client network calls I see a request to https://slack.com/api/subscriptions.thread.add? however, that only seems to work with xoxc tokens from what I can tell, and those are not officially supported tokens. Moreover, that end point isn't listed in the documentation.
When I try that endpoint with my xoxp token, with all OAuth permissions I could add, results in:
"ok": false,
"error": "not_allowed_token_type",
Does anyone know how I might be able to achieve my goal of programmatically following a message? I'm sure I could post a message in the thread to achieve the same goal, but that is really messy and clutters the thread with noise.
Thanks!

Related

Webhook time out doesn't follow documentation

According to the Conversations API documentation in the case where a pre-action webhook fails to get a response:
(no response or timeout)
then
Conversations will publish the change unmodified after a series of retries; your messages will be delayed accordingly.
However it looks like the actual result is that Twilio returns an error to the mobile SDK when the webhook post times out.
Honestly the current response is the one I was hoping for, but since the documentation makes it seem like this is a bug, I just wanted clarification of what the expected result SHOULD be, before making any assumptions that break my stuff later on.

Graph API calls to OnPremise Exchange only works in Playground

Our setup is an on-premise Exchange Server which is accessible over the graph api. https://learn.microsoft.com/en-us/graph/hybrid-rest-support
We run in the issue, that our token is only "partial" working. And a token created by "Graph-Playground" is fully working. But we can't find any difference.
When I use Graph-Playground or use the token generated by Graph-Playground => all requests are working
When I create a token (over my app registration) => only some requests are working
The token seems to be valid some calls like /me are working, but all calls related to exchange like /me/contacts are failing with this error
Request, they work with token generated by Postman:**
Error:
{ "error": { "code": "MailboxNotEnabledForRESTAPI", "message": "REST API is not yet supported for this mailbox." } }
(that's a very generic error, and mostly don't say anything about the real issue)
Token Generation:
I create my token on the same way as Graph-Playground create the token (OAuth - Implicit flow):
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=token&state=test2&client_id=????&scope=openid%20profile%20User.Read%20email%20Contacts.Read&redirect_uri=????
Token - Analysis:
As a side note, it was working for a few days, nobody changed anything :)
So I have no idea, why the "Graph Playground" can create a working token, and my token only "partially" works. Can you help me?
There is already a thread, but I'm not the owner of it. Also there are no more responses... I can't provide a bounty for a foreign thread, that's why I create a new thread. You can find it here:
MailboxNotEnabledForRESTAPI - Microsoft Graph API integration with HMA Enabled on-premise server
I recognize your error, we see it in several cases (for Office 365):
User has no Exchange license (probably not the case, since it works in the explorer).
Customer tenant has setup additional security.
You can limit applications to certain mailboxes. Maybe there is some kind of setting or policy like this on your local Exchange as well, you have to connect to Exchange Online Powershell to set it, so maybe you can find something there. This is just a wild guess.
To track down this issue I would start checking the local Exchange logs.
Have you tried using the /users/{upn}/calendar endpoint? Maybe it's just that the /me/ part doesn't work.

Programatically get New Access Token for oAuth 2.0 in Postman

In Postman, I am able to successfully request a new token using the GUI. I'm wondering how to do this programatically. Or at least see the HTTP request that Postman is making. I've tried viewing it by monitoring the network traffic in Chrome, and with Wireshark, but without success. Thank you
well, OAuth2 is quite a big subject and you are not really providing a lot of details.
Postman is just a client, it creates requests based on the data you gave it so you don't need to monitor anything, you should know how you set it up and then simply mirror that in whatever language you want. Look at headers and post data specifically.
All I can do is point you to an extensive article I wrote on OAuth2, it shows a complete implementation, how to use Postman to create the correct requests and then how to write code which makes it all work.
If you don't use dot net, you can still understand all the concepts and it should be trivial to do the same thing using a different language.
https://eidand.com/2015/03/28/authorization-system-with-owin-web-api-json-web-tokens/

Bigcommerce API (oAuth) Webhook Request - what is {secret_auth_password}?

UPDATE: All calls to the API receive the following response:
failed [500] An error has occurred
Weirdly, my auth process (documented here) works perfectly, while all calls to the API (documented here), fail.
The Bigcommerce API is in transition from basic auth to oAuth. The documentation is consequently a little confusing.
I am trying to create a webhook using the new oAuth methodology. The documentation states that I need an oAuth access_token for the relevant store, which I have obtained.
The documentation also includes sample http request data:
{
"scope": "store/order/*",
"headers": {
"X-Custom-Auth-Header": "{secret_auth_password}"
},
"destination": "https://app.example.com/orders",
"is_active": true
}
In this context, I am assuming that {secret_auth_password} refers to the store's access_token. However, when I include the access_token here I get the following error:
failed [401] You are not authorized.
Thinking that this might be a scoping/permission issue, I have given my app the highest possible level of access through the app settings, but this did not work either.
Thanks in advance for any pointers.
Well after a couple of days of serious head-scratching (not to mention hair out-tearing) I worked out that this was all down to an error in my SSL intermediate certificate, which I have now fixed.
It was the old API returning an error of “UNABLE_TO_VERIFY_LEAF_SIGNATURE” that put me on the right track – the new API just returned:
500 – there is an error
or
404 – you are not authorized.
If you are using PHP I would recommend using the the Webhooks pull request combined with the OAuth pull request. They are both working fine together (I personally use them).
Webhooks pull - https://github.com/bigcommerce/bigcommerce-api-php/pull/101
OAuth pull - https://github.com/bigcommerce/bigcommerce-api-php/pull/88
Then to create a webhook you can just call createWebhook($object)
Object needs to include scope and destination.
Also - a side note.. Are you using SSL for the destination address. It won't work otherwise. You can use a self-signed cert to get around this though.
This will only work for setting up the webhooks though.
To actually receive them you need a valid certificate (else you get nothing).
Hope this helps.
I came across this same part of the documentation and was also confused by it. The proper headers to send for webhooks are the following:
"X-Auth-Client":"[YOUR_APPS_CLIENT_ID]",
"X-Auth-Token":"[OAUTH_ACCESS_TOKEN]"
In addition to using the headers that #FlyingL123 suggested, also take note of of the requirements as noted by BigCommerce:
Requirements
The following properties of the webhooks are required. The request
won’t be fulfilled unless these properties are valid.
scope
destination

How to deal with Twitter API Limits?

I have this project that's based on a Twitter Bot. NOT an abusive or spammer bot. Just a robot that will reply with information about my system when it's mentioned.
The thing is: I expect to have about 3000 mentions/hour. Which means I have to send about 3000 replies/hour.
I know Twitter API calls are limited to 350/h when the app is authenticated and 150/h when it's not. But I've also read about it being 1000/h somewhere in the Twitter Discussion boards.
Anyway, how can I deal with having to send so many replies/hour?
I thought about creating multiple Twitter accounts and delegating some of the replies to them in order to being able to reply to all of them, but I do realize it's not a pretty solution.
Does anyone have a better idea?
Your best bet is to use Streaming.
Connecting
API Params (JSON)
Basically, you open up a connection with their server with your credentials and instead of reading the return stream and closing, you just keep reading. When you want to make a request, you just send another header or something.

Resources