Skip to content

Commit 2608428

Browse files
committed
Merge pull request #40 from CloudCannon/master
added access_token support
2 parents bc2ba2f + 624cc33 commit 2608428

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lib/bitbucket_rest_api/configuration.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module Configuration
77
:adapter,
88
:client_id,
99
:client_secret,
10+
:new_access_token,
1011
:oauth_token,
1112
:oauth_secret,
1213
:endpoint,
@@ -29,6 +30,9 @@ module Configuration
2930
# By default, don't set an application secret
3031
DEFAULT_CLIENT_SECRET = nil
3132

33+
# By default, don't set an access token
34+
DEFAULT_ACCESS_TOKEN = nil
35+
3236
# By default, don't set a user oauth access token
3337
DEFAULT_OAUTH_TOKEN = nil
3438

@@ -83,6 +87,7 @@ def set_defaults
8387
self.adapter = DEFAULT_ADAPTER
8488
self.client_id = DEFAULT_CLIENT_ID
8589
self.client_secret = DEFAULT_CLIENT_SECRET
90+
self.new_access_token = DEFAULT_ACCESS_TOKEN
8691
self.oauth_token = DEFAULT_OAUTH_TOKEN
8792
self.oauth_secret = DEFAULT_OAUTH_SECRET
8893
self.endpoint = DEFAULT_ENDPOINT

lib/bitbucket_rest_api/request.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Request
1010
def get_request(path, params={}, options={})
1111
request(:get, path, params, options)
1212
end
13-
13+
1414

1515
def patch_request(path, params={}, options={})
1616
request(:patch, path, params, options)
@@ -40,6 +40,7 @@ def request(method, path, params, options)
4040
path = (conn.path_prefix + path).gsub(/\/\//,'/') if conn.path_prefix != '/'
4141

4242
response = conn.send(method) do |request|
43+
request['Authorization'] = "Bearer #{new_access_token}" unless new_access_token.nil?
4344
case method.to_sym
4445
when *(METHODS - METHODS_WITH_BODIES)
4546
request.body = params.delete('data') if params.has_key?('data')

lib/bitbucket_rest_api/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module BitBucket
44
module VERSION
55
MAJOR = 0
66
MINOR = 1
7-
PATCH = 6
7+
PATCH = 7
88

99
STRING = [MAJOR, MINOR, PATCH].compact.join('.')
1010
end

0 commit comments

Comments
 (0)