1

First Question: So, I'm attempting to post an image to a specific slack channel using the files.upload API call in the Slack APIs. I have a client_id and a client_secret. I just want this to be used for my team using slack to communicate. Is this possible without getting an access token through OAuth 2?

Secondary question: In my attempt to go through OAuth 2, I have placed my client_id into a python dictionary and then json.dumps() it. I stored the id in the field 'client_id' yet the message returned is "OAuth message: please specify a 'client_id'" Why is this an error? Should I name it something other than 'client_id'?

EDIT: I found the answer to question 2. I don't receive what I expected, but simply sending the dictionary without turning into a JSON object solved the client_id issue.

Cody Berry
  • 263
  • 3
  • 14

1 Answers1

1

You always need an access token to upload a file with the Slack API.

But you can install your Slack app to your own Slack workspace without going through the OAuth process yourself. Just create your Slack app and go to the "Install App" page your app. Which you find under Manage your apps.

Example screenshot: enter image description here

Another option (although not recommended) is to us a legacy token. You can create it here: https://api.slack.com/custom-integrations/legacy-tokens

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
  • Okay, so just to be clear, I can go to the settings icon for the channel and then the "add app" button so that I don't need to go through the OAuth process? – Cody Berry Feb 19 '18 at 16:05
  • Not quite. it has nothing to do with channels. You need to install your Slack app (same that has the client id you mentioned) to your Slack workspace. – Erik Kalkoken Feb 19 '18 at 16:08
  • 1
    Awesome, thank you! One last followup. Will doing this give me a new access token or will I be able to use files.upload with my client_id? – Cody Berry Feb 19 '18 at 16:10
  • I apologize, but I'm not sure if my edit notified you. Will doing this give me a new access token that I use or will I then just use my client_id/client_secret for posting to the workspace? I only ask because someone else created the app and then asked me to write the app. I just need to know what to ask them for. – Cody Berry Feb 19 '18 at 16:33
  • It is not possible to use client id/secret directly for the API. You always need an access token. Which you can get through Oauth by using the client id / secret though. If someone else create the app ask them to add you as "collaborator", so you get access to the Slack app. And yes, you will get a new access token with "Install App to Workspace". – Erik Kalkoken Feb 19 '18 at 17:01
  • Also, you only have to run through Oauth / install the app once. the access token you then receive will be valid forever. – Erik Kalkoken Feb 19 '18 at 17:04