34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/databasedotcom-oauth2.rb', line 34
def self.from_token(token, api_version)
client = nil
unless token.nil?
client = self.new({
:client_id => token.client.id,
:client_secret => token.client.secret,
:host => Databasedotcom.parse_domain(token.client.site)
})
m = token["id"].match(/\/id\/([^\/]+)\/([^\/]+)$/)
client.org_id = m[1] rescue nil
client.user_id = m[2] rescue nil
client.version = api_version
client.instance_url = token.client.site
client.oauth_token = token.token
client.refresh_token = token.refresh_token
end
client
end
|