Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit c69c640

Browse files
Merge pull request #1301 from johnwyles/bitly.coffee
Updating decrecated bit.ly API apiKey in favor of OAuth token
2 parents c29ef44 + 4050960 commit c69c640

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/scripts/bitly.coffee

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
# None
66
#
77
# Configuration:
8-
# HUBOT_BITLY_USERNAME
9-
# HUBOT_BITLY_API_KEY
8+
# HUBOT_BITLY_ACCESS_TOKEN
109
#
1110
# Commands:
1211
# hubot (bitly|shorten) (me) <url> - Shorten the URL using bit.ly
@@ -15,14 +14,14 @@
1514
# Author:
1615
# sleekslush
1716
# drdamour
17+
# johnwyles
1818

1919
module.exports = (robot) ->
2020
robot.respond /(bitly|shorten)\s?(me)?\s?(.+)$/i, (msg) ->
2121
msg
22-
.http("http://api.bitly.com/v3/shorten")
22+
.http("https://api-ssl.bitly.com/v3/shorten")
2323
.query
24-
login: process.env.HUBOT_BITLY_USERNAME
25-
apiKey: process.env.HUBOT_BITLY_API_KEY
24+
access_token: process.env.HUBOT_BITLY_ACCESS_TOKEN
2625
longUrl: msg.match[3]
2726
format: "json"
2827
.get() (err, res, body) ->
@@ -32,10 +31,9 @@ module.exports = (robot) ->
3231
#TODO: can we make this list more expansive/dynamically generated?
3332
robot.hear /(https?:\/\/(bit\.ly|yhoo\.it|j\.mp|pep\.si|amzn\.to)\/[0-9a-z\-]+)/ig, (msg) ->
3433
msg
35-
.http("http://api.bitly.com/v3/expand")
34+
.http("https://api-ssl.bitly.com/v3/expand")
3635
.query
37-
login: process.env.HUBOT_BITLY_USERNAME
38-
apiKey: process.env.HUBOT_BITLY_API_KEY
36+
access_token: process.env.HUBOT_BITLY_ACCESS_TOKEN
3937
shortUrl: msg.match
4038
.get() (err, res, body) ->
4139
parsedBody = JSON.parse body

0 commit comments

Comments
 (0)