OAuth2::AccessToken#refresh! returns new object, not itself
It is a common practice that when we use bang! methods methods are performed to object itself.
On line https://github.com/intridea/oauth2/blob/master/lib/oauth2/access_token.rb#L99 #refresh! method returns new token, so we can not use it in such way:
def try_refresh
# some work
token.refresh!
# more work
token
end
Instead we should use temporary variable, like this:
def try_refresh
# some work
new_token = token.refresh!
# more work
new_token
end