How to send commands on behalf of another user with slack api - python

I am building a Slack app which is similar to the fuck command line tool. It's supposed to find typos of users trying to execute a command and execute the correct command on their behalf.
I searched a lot and find unofficial document about the chat.command api which is useful, but I need to send a command as another user. The approach I am taking right now is to ask the user for his or her legacy token on the channel, then save it on db for sending commands on behalf of them. But it's not practical
slack.legacy_client.api_call(
"chat.command",
channel='channel_id',
command='/command',
text='do stuff',
)
Is there a better way to send command on behalf of another user?

I think that the only way to do this is to, as you say, save off the token. Otherwise there's no way that Slack will know that you are able to execute as the other use. As part of installing the application, you might add a configuration step that each user will have to go through to set up the tool, and save off the token there.
You can use the database, as you suggest. Another alternative is to use a platform like Tranposit (full disclosure, I'm employed there). They've built a system to store off users' tokens (for Slack and other APIs, though Slack is the relevant API here). More info here: https://www.transposit.com/docs/building/managed-authentication/

Related

How should i go about detecting user connections with firebase

I'm asking here because I could really find an answer elsewhere I was trying to get into firebase and I'm wondering how could I check whether a user is connected or not and things like that
for example, let's say john connects I would update his status to say online but if he lost connection how would I go about this? I'm thinking about something like a separate application that starts a trigger and if an account doesn't periodically refresh that trigger they go offline but that sounds really inefficient so I am a bit stumped. not currently using the inbuilt auth by the way
There is a great explanation of how to do this in the Firebase documentation under managing presence and also a complete example presence system.
This is only available on the main platforms where Firebase offers a client-side SDK: iOS, Android, and web. Since you tagged with Python, it might not apply to you.
As far as I can see from scanning the reference documentation for the Python Admin SDK, there is no equivalent onDisconnect() available.

What does it mean to use an API key in server-side auth flow?

New to programming, using Python 3.
I work in sales and want to make a program using the Podio API which is going to take information about potential clients from an excel sheet and use it to create subpages in Podio with their information. To get an API-key, Podio wants a redirect-URL for the purposes described here and here, a whole bunch of text I don't really understand. Does it mean I have to authenticate myself in my program (using my Podio login info?), which sends me to Podio (where I log in to Podio manually, using the same login info?), which sends me to the redirect URL, which sends me back to Podio? I can't really make sense of this.
I googled and found some similar questions but none of the answers explained exactly what the actual functions of these authentication flows are. When do I need them? Do I need them if I'm just going to be using this program myself? Do I always need them to gain access to my Podio account through my program?
Thanks in advance.
If you are only going to use your program yourself, then username/password flow is what you need. It is simplest to understand and use flow of authenticating with Podio API. Here are all needed details for it: https://developers.podio.com/authentication/username_password
To be short: yes, you can enter localhost as full domain (without protocol) of your return URL

Python to Facebook message, no xmpp authorisation

I am trying to develop a python script that will automatically send a private facebook message to one user.
I have followed the procedure here but this uses the xmpp access tokens.
From what I have read, this is no longer supported.
Does anyone know of a suitable work around?
Thanks for any help
You can only send messages with the official ways (Send Dialog, Facebook Messenger, ...).
Take a look at the Send Dialog: https://developers.facebook.com/docs/sharing/reference/send-dialog
Most likely it´s what you need.

google API - python outh2 application authentication

I have a simple scenario for which I can't find solution. I'd like to use Docs API for my application, but I want to use only one application account to store documents and perform all the API calls. So I don't want to use all this redirect_uri stuff, that needs any kind of user interaction - only my app and it's own Google account.
I've found similar question here: gdata-python-api + Analytics with simple auth but the solution still involves user interaction (yes, probably only once but I still don't like it as most of the interactions with API will be done by some daemon).
I'm using gdata-python-client for interactions with API. I'm not sure if I understand correctly if ServiceAccount authentication might be a solution, but couldn't find any examples of how to perform it via gdata-python-client lib (can somebody share working code?).
To access the documents owned by this single user, you must have an access token for that user. There's not really any way around this. The access token is how Google identifies your project, which user's data you'd like access to, and that you have all of the necessary permissions granted.
It sounds like you've already found the solution: You must go through the OAuth 2.0 dance at some point in time and store the refresh_token for subsequent access. Be aware, though, that refresh_tokens may not last forever. For example, if access is revoked, it will stop working. For this reason, it's wise to expose the ability to execute the OAuth 2.0 dance again from an administrative page in your application.

Getting a Jabber status via Python

I'm developing a website using the Django framework, and I need to retrieve Jabber (okay, Google Talk) statuses for a user. Most of the Jabber python libraries seem like an incredible amount of overkill (and overhead) for a simple task. Is there any simple way to do this?
I know very little about XMPP/Jabber, though of course I'm willing to learn. Do you need to be an authenticated and "friended" user to retrieve another user's status?
Do you need to be an authenticated and
"friended" user to retrieve another
user's status?
Yes.
To get the status of a given user, you should write a jabber bot and the user should add your bot as a friend. Then you would be able to get the status of that user. FriendFeed and other services do that.
Google Buzz is from Google, so they already have access to your chat status...
I recommend checking out Google AppEngine's XMPP API (Django runs on AppEngine, too). AFAIK you have to be authorized to check a user's status.

Categories