Skip to content

Commit

Permalink
Token param is not required if custom endpoint provided (Closes: #48)
Browse files Browse the repository at this point in the history
  • Loading branch information
lamby committed May 10, 2016
1 parent 826d9d8 commit 39a41d6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion django_slack/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def slack_message(template, context=None, attachments=None, fail_silently=None,
},
'token': {
'default': app_settings.TOKEN,
'required': True,
'required': False,
},
'channel': {
'default': app_settings.CHANNEL,
Expand Down Expand Up @@ -88,6 +88,13 @@ def slack_message(template, context=None, attachments=None, fail_silently=None,
# If a custom endpoint URL was specified then we need to wrap it, otherwise
# we need to ensure attachments are encoded.
if endpoint_url == app_settings.DEFAULT_ENDPOINT_URL:
if not data.get('token'):
if fail_silently:
return

raise ValueError("token parameter is required if custom " \
"endpoint URL is not specified")

# As a special case, if a custom endpoint is not set (eg. for a
# private channel), then the channel parameter is not required.
if not data.get('channel'):
Expand Down

0 comments on commit 39a41d6

Please sign in to comment.