lib/aptible/auth/token.rb
# Unlike other resources, tokens aren't created in a REST fashion.
# Instead, they're created via OAuth grants. This means we need to
# override the way HyperResource / aptible-resource normally do things
# and plug in an OAuth library.
#
# To do so, we take control of the creation arguments and feed them into
# the OAuth2 library (in Token.create!), and then feed the response back
# to HyperResource (in Token#apply_oauth_response).
Unlike other resources, tokens aren't created in a REST fashion.
Instead, they're created via OAuth grants. This means we need to
override the way HyperResource / aptible-resource normally do things
and plug in an OAuth library.

To do so, we take control of the creation arguments and feed them into
the OAuth2 library (in Token.create!), and then feed the response back
to HyperResource (in Token#apply_oauth_response).
Unlike other resources tokens aren ' t created in a REST fashion . Instead they ' re created via OAuth grants . This means we need to override the way HyperResource / aptible - resource normally do things and plug in an OAuth library . To do so we take control of the creation arguments and feed them into the OAuth2 library ( in Token . create! ) and then feed the response back to HyperResource ( in Token#apply_oauth_response ) .
def token_as_string(tok)
        return nil if tok.nil?
        case tok
        when Aptible::Resource::Base then tok.access_token
        when Fridge::AccessToken then tok.to_s
        when String then tok
        else
          raise "Unrecognized token: #{tok.class}: #{tok}"
        end
      end
def token_as_string ( tok ) return nil if tok . nil? case tok when Aptible :: Resource :: Base then tok . access_token when Fridge :: AccessToken then tok . to_s when String then tok else raise "Unrecognized token: #{tok.class}: #{tok}" end end
Unlike other resources, tokens aren't created in a REST fashion.
Unlike other resources tokens aren ' t created in a REST fashion .
# TODO: This duplicates aptible-resource, is it worth extracting?
tok