· 7 years ago · Jan 24, 2018, 06:48 PM
1 def access_token(master)
2 @auth_url = '/oauth/token'
3 consumer = OAuth2::Client.new(master.client_id,
4 master.client_secret,
5 :site => master.site)
6
7 consumer.auth_code.authorize_url(:redirect_uri => @auth_url)
8 token = consumer.auth_code.get_token(:redirect_uri => @auth_url)
9
10
11 #response = consumer.request(:post, @auth_url, {:grant_type => 'password',
12 # :client_id => master.client_id,
13 # :client_secret => master.client_secret,
14 # :username => master.username,
15 # :password => master.password,
16 # :scope => 'read_projects write_projects'})
17
18
19 #OAuth2::AccessToken.new(consumer, response['access_token']).token
20
21 end