Skip to content

Commit

Permalink
Merge pull request grpc#3267 from jtattermusch/service_account_creds_…
Browse files Browse the repository at this point in the history
…for_per_rpc_test

Use service account credentials for per RPC test
  • Loading branch information
murgatroid99 committed Sep 4, 2015
2 parents 350561c + bea7cbd commit d91e5c6
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/csharp/Grpc.IntegrationTesting/InteropClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private async Task RunTestCaseAsync(TestService.TestServiceClient client, Client
await RunOAuth2AuthTokenAsync(client, options.DefaultServiceAccount, options.OAuthScope);
break;
case "per_rpc_creds":
await RunPerRpcCredsAsync(client, options.DefaultServiceAccount);
await RunPerRpcCredsAsync(client, options.DefaultServiceAccount, options.OAuthScope);
break;
case "cancel_after_begin":
await RunCancelAfterBeginAsync(client);
Expand Down Expand Up @@ -391,14 +391,11 @@ public static async Task RunOAuth2AuthTokenAsync(TestService.TestServiceClient c
Console.WriteLine("Passed!");
}

public static async Task RunPerRpcCredsAsync(TestService.TestServiceClient client, string defaultServiceAccount)
public static async Task RunPerRpcCredsAsync(TestService.TestServiceClient client, string defaultServiceAccount, string oauthScope)
{
Console.WriteLine("running per_rpc_creds");

ITokenAccess credential = await GoogleCredential.GetApplicationDefaultAsync();
// TODO: currently there's no way how to obtain AuthURI for JWT per-rpc creds.
string authUri = "https://grpc-test.sandbox.google.com/grpc.testing.TestService";
string accessToken = await credential.GetAccessTokenForRequestAsync(authUri);
ITokenAccess credential = (await GoogleCredential.GetApplicationDefaultAsync()).CreateScoped(new[] { oauthScope });
string accessToken = await credential.GetAccessTokenForRequestAsync();
var headerInterceptor = AuthInterceptors.FromAccessToken(accessToken);

var request = new SimpleRequest
Expand Down

0 comments on commit d91e5c6

Please sign in to comment.