Merge pull request #112 from hxiong388/new-token-uri
Upgrade to new token URI
This commit is contained in:
commit
0dab02dbaa
|
@ -46,7 +46,7 @@ module Google
|
||||||
#
|
#
|
||||||
# cf [Application Default Credentials](http://goo.gl/mkAHpZ)
|
# cf [Application Default Credentials](http://goo.gl/mkAHpZ)
|
||||||
class ServiceAccountCredentials < Signet::OAuth2::Client
|
class ServiceAccountCredentials < Signet::OAuth2::Client
|
||||||
TOKEN_CRED_URI = 'https://www.googleapis.com/oauth2/v3/token'.freeze
|
TOKEN_CRED_URI = 'https://www.googleapis.com/oauth2/v4/token'.freeze
|
||||||
extend CredentialsLoader
|
extend CredentialsLoader
|
||||||
|
|
||||||
# Creates a ServiceAccountCredentials.
|
# Creates a ServiceAccountCredentials.
|
||||||
|
@ -119,7 +119,7 @@ module Google
|
||||||
class ServiceAccountJwtHeaderCredentials
|
class ServiceAccountJwtHeaderCredentials
|
||||||
JWT_AUD_URI_KEY = :jwt_aud_uri
|
JWT_AUD_URI_KEY = :jwt_aud_uri
|
||||||
AUTH_METADATA_KEY = Signet::OAuth2::AUTH_METADATA_KEY
|
AUTH_METADATA_KEY = Signet::OAuth2::AUTH_METADATA_KEY
|
||||||
TOKEN_CRED_URI = 'https://www.googleapis.com/oauth2/v3/token'.freeze
|
TOKEN_CRED_URI = 'https://www.googleapis.com/oauth2/v4/token'.freeze
|
||||||
SIGNING_ALGORITHM = 'RS256'.freeze
|
SIGNING_ALGORITHM = 'RS256'.freeze
|
||||||
EXPIRY = 60
|
EXPIRY = 60
|
||||||
extend CredentialsLoader
|
extend CredentialsLoader
|
||||||
|
|
|
@ -46,7 +46,7 @@ module Google
|
||||||
#
|
#
|
||||||
# cf [Application Default Credentials](http://goo.gl/mkAHpZ)
|
# cf [Application Default Credentials](http://goo.gl/mkAHpZ)
|
||||||
class UserRefreshCredentials < Signet::OAuth2::Client
|
class UserRefreshCredentials < Signet::OAuth2::Client
|
||||||
TOKEN_CRED_URI = 'https://www.googleapis.com/oauth2/v3/token'.freeze
|
TOKEN_CRED_URI = 'https://www.googleapis.com/oauth2/v4/token'.freeze
|
||||||
AUTHORIZATION_URI = 'https://accounts.google.com/o/oauth2/auth'.freeze
|
AUTHORIZATION_URI = 'https://accounts.google.com/o/oauth2/auth'.freeze
|
||||||
REVOKE_TOKEN_URI = 'https://accounts.google.com/o/oauth2/revoke'.freeze
|
REVOKE_TOKEN_URI = 'https://accounts.google.com/o/oauth2/revoke'.freeze
|
||||||
extend CredentialsLoader
|
extend CredentialsLoader
|
||||||
|
|
|
@ -137,7 +137,7 @@ describe Google::Auth::ServiceAccountCredentials do
|
||||||
_claim, _header = JWT.decode(params.assoc('assertion').last,
|
_claim, _header = JWT.decode(params.assoc('assertion').last,
|
||||||
@key.public_key)
|
@key.public_key)
|
||||||
end
|
end
|
||||||
stub_request(:post, 'https://www.googleapis.com/oauth2/v3/token')
|
stub_request(:post, 'https://www.googleapis.com/oauth2/v4/token')
|
||||||
.with(body: hash_including(
|
.with(body: hash_including(
|
||||||
'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer'
|
'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer'
|
||||||
),
|
),
|
||||||
|
|
|
@ -242,7 +242,7 @@ describe Google::Auth::UserAuthorizer do
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:example) do
|
before(:example) do
|
||||||
stub_request(:post, 'https://www.googleapis.com/oauth2/v3/token')
|
stub_request(:post, 'https://www.googleapis.com/oauth2/v4/token')
|
||||||
.to_return(body: token_json, status: 200, headers: {
|
.to_return(body: token_json, status: 200, headers: {
|
||||||
'Content-Type' => 'application/json'
|
'Content-Type' => 'application/json'
|
||||||
})
|
})
|
||||||
|
@ -270,7 +270,7 @@ describe Google::Auth::UserAuthorizer do
|
||||||
|
|
||||||
context 'with invalid authorization code' do
|
context 'with invalid authorization code' do
|
||||||
before(:example) do
|
before(:example) do
|
||||||
stub_request(:post, 'https://www.googleapis.com/oauth2/v3/token')
|
stub_request(:post, 'https://www.googleapis.com/oauth2/v4/token')
|
||||||
.to_return(status: 400)
|
.to_return(status: 400)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ describe Google::Auth::UserRefreshCredentials do
|
||||||
body = MultiJson.dump('access_token' => access_token,
|
body = MultiJson.dump('access_token' => access_token,
|
||||||
'token_type' => 'Bearer',
|
'token_type' => 'Bearer',
|
||||||
'expires_in' => 3600)
|
'expires_in' => 3600)
|
||||||
stub_request(:post, 'https://www.googleapis.com/oauth2/v3/token')
|
stub_request(:post, 'https://www.googleapis.com/oauth2/v4/token')
|
||||||
.with(body: hash_including('grant_type' => 'refresh_token'))
|
.with(body: hash_including('grant_type' => 'refresh_token'))
|
||||||
.to_return(body: body,
|
.to_return(body: body,
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|
|
@ -107,7 +107,7 @@ describe Google::Auth::WebUserAuthorizer do
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:example) do
|
before(:example) do
|
||||||
stub_request(:post, 'https://www.googleapis.com/oauth2/v3/token')
|
stub_request(:post, 'https://www.googleapis.com/oauth2/v4/token')
|
||||||
.to_return(body: token_json,
|
.to_return(body: token_json,
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: { 'Content-Type' => 'application/json' })
|
headers: { 'Content-Type' => 'application/json' })
|
||||||
|
|
Loading…
Reference in New Issue