Beispiel #1
0
 /// <summary>Constructs a new impersonated credential using the given initializer.</summary>
 internal ImpersonatedCredential(Initializer initializer) : base(initializer)
 {
     SourceCredential = initializer.SourceCredential.ThrowIfNull("initializer.SourceCredential");
     if (!(SourceCredential.UnderlyingCredential is UserCredential || SourceCredential.UnderlyingCredential is ServiceAccountCredential))
     {
         throw new InvalidOperationException("The underlying credential of source credential must be UserCredential or ServiceAccountCredential.");
     }
     SourceCredential = SourceCredential.CreateScoped(new string[] { GoogleAuthConsts.IamScope });
     HttpClient.MessageHandler.Credential = SourceCredential.UnderlyingCredential as Http.IHttpExecuteInterceptor;
     Options = initializer.Options;
 }
Beispiel #2
0
 internal Initializer(ImpersonatedCredential other) : base(other.TokenServerUrl)
 {
     SourceCredential = other.SourceCredential;
     Options          = other.Options;
 }
Beispiel #3
0
 /// <summary>Constructs a new initializer.</summary>
 /// <param name="sourceCredential">The source credential used to acquire the impersonated credentials.</param>
 /// <param name="options">The impersonation options.</param>
 public Initializer(GoogleCredential sourceCredential, ImpersonationOptions options)
     : base(String.Format(GoogleAuthConsts.IamAccessTokenEndpointFormatString, options.TargetPrincipal))
 {
     SourceCredential = sourceCredential;
     Options          = options;
 }