diff --git a/lib/googleauth/compute_engine.rb b/lib/googleauth/compute_engine.rb index 28654a3..a11c422 100644 --- a/lib/googleauth/compute_engine.rb +++ b/lib/googleauth/compute_engine.rb @@ -107,7 +107,7 @@ module Google retry_with_error do uri = target_audience ? GCECredentials.compute_id_token_uri : GCECredentials.compute_auth_token_uri query = target_audience ? { "audience" => target_audience, "format" => "full" } : {} - query[:scopes] = Array(scope).join " " if scope + query[:scopes] = Array(scope).join "," if scope headers = { "Metadata-Flavor" => "Google" } resp = c.get uri, query, headers case resp.status diff --git a/spec/googleauth/compute_engine_spec.rb b/spec/googleauth/compute_engine_spec.rb index 2058981..156e55f 100644 --- a/spec/googleauth/compute_engine_spec.rb +++ b/spec/googleauth/compute_engine_spec.rb @@ -53,7 +53,7 @@ describe Google::Auth::GCECredentials do "expires_in" => 3600) uri = MD_ACCESS_URI - uri += "?scopes=#{opts[:scope]}" if opts[:scope] + uri += "?scopes=#{Array(opts[:scope]).join ','}" if opts[:scope] stub_request(:get, uri) .with(headers: { "Metadata-Flavor" => "Google" }) @@ -74,9 +74,9 @@ describe Google::Auth::GCECredentials do context "metadata is unavailable" do describe "#fetch_access_token" do it "should pass scopes when requesting an access token" do - scope = "https://www.googleapis.com/auth/drive" - stub = make_auth_stubs access_token: "1/abcdef1234567890", scope: scope - @client = GCECredentials.new(scope: [scope]) + scopes = ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/bigtable.data"] + stub = make_auth_stubs access_token: "1/abcdef1234567890", scope: scopes + @client = GCECredentials.new(scope: scopes) @client.fetch_access_token! expect(stub).to have_been_requested end