aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorA. Jesse Jiryu Davis <jesse@mongodb.com>2018-01-15 16:55:42 -0500
committerA. Jesse Jiryu Davis <jesse@mongodb.com>2018-01-15 16:56:51 -0500
commit72e4149ce3bdc87536d73ca5b77838734d9dced7 (patch)
treee2452639b39dd596c28511d09809b9bd10677424
parent30139cd31c9655f9e4c65775a5a4ea6809b72e76 (diff)
downloadwee-slack-72e4149ce3bdc87536d73ca5b77838734d9dced7.tar.gz
update oauth logic for new command code
-rw-r--r--wee_slack.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 5bdb30d..1e212a9 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2964,10 +2964,10 @@ def me_command_cb(data, current_buffer, args):
return w.WEECHAT_RC_OK_EAT
-def command_register(current_buffer, args):
+def command_register(data, current_buffer, args):
CLIENT_ID="2468770254.51917335286"
CLIENT_SECRET="dcb7fe380a000cba0cca3169a5fe8d70" #this is not really a secret
- if not args:
+ if args == 'register':
message = """
#### Retrieving a Slack token via OAUTH ####
@@ -2983,11 +2983,14 @@ def command_register(current_buffer, args):
w.prnt(current_buffer, message)
else:
aargs = args.split(None, 2)
- if len(aargs) <> 1:
+ if len(aargs) != 2:
w.prnt(current_buffer, "ERROR: invalid args to register")
else:
- #w.prnt(current_buffer, "https://slack.com/api/oauth.access?client_id={}&client_secret={}&code={}".format(CLIENT_ID, CLIENT_SECRET, aargs[0]))
- ret = urllib.urlopen("https://slack.com/api/oauth.access?client_id={}&client_secret={}&code={}".format(CLIENT_ID, CLIENT_SECRET, aargs[0])).read()
+ uri = (
+ "https://slack.com/api/oauth.access?"
+ "client_id={}&client_secret={}&code={}"
+ ).format(CLIENT_ID, CLIENT_SECRET, aargs[1])
+ ret = urllib.urlopen(uri).read()
d = json.loads(ret)
if d["ok"] == True:
w.prnt(current_buffer, "Success! Access token is: " + d['access_token'])