lib/twitter/client.rb in twitter-4.8.0 vs lib/twitter/client.rb in twitter-4.8.1

- old
+ new

@@ -91,11 +91,11 @@ request.headers[:authorization] = bearer_token_credentials_auth_header request.headers[:content_type] = 'application/x-www-form-urlencoded; charset=UTF-8' request.headers[:accept] = '*/*' # It is important we set this, otherwise we get an error. elsif params.delete(:app_auth) || !user_token? unless bearer_token? - @bearer_token = token[:access_token] + @bearer_token = token Twitter.client.bearer_token = @bearer_token if Twitter.client? end request.headers[:authorization] = bearer_auth_header else request.headers[:authorization] = oauth_auth_header(method, path, signature_params).to_s @@ -130,10 +130,14 @@ def encode_value(value) [value].pack("m0").gsub("\n", '') end def bearer_auth_header - "Bearer #{@bearer_token}" + if @bearer_token.is_a?(Twitter::Token) && @bearer_token.token_type == "bearer" + "Bearer #{@bearer_token.access_token}" + else + "Bearer #{@bearer_token}" + end end def oauth_auth_header(method, path, params={}) uri = URI(@endpoint + path) SimpleOAuth::Header.new(method, uri, params, credentials)