Note that there are some explanatory texts on larger screens.

plurals
  1. POAuthenticating to Google API with OAuth2
    primarykey
    data
    text
    <p>I am trying out the sample code from <a href="https://developers.google.com/drive/delegation" rel="nofollow">Perform Google Apps Domain-wide Delegation of Authority</a> using C# / .NET and, like in some other samples I have tried, the part of the code that creates an object that uses the auth variable says that they syntax is wrong. Here is the code I have:</p> <pre><code>using System; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using DotNetOpenAuth.OAuth2; using Google.Apis.Authentication.OAuth2; using Google.Apis.Authentication.OAuth2.DotNetOpenAuth; using Google.Apis.Drive.v2; using Google.Apis.Util; namespace GoogleAPIDemo { class DriveServiceObject { private const string SERVICE_ACCOUNT_EMAIL = "&lt;some-id&gt;@developer.gserviceaccount.com"; private const string SERVICE_ACCOUNT_PKCS12_FILE_PATH = @"\path\to\&lt;public_key_fingerprint&gt;-privatekey.p12"; /// &lt;summary&gt; /// Build a Drive service object authorized with the service account /// that acts on behalf of the given user. /// &lt;/summary&gt; /// @param userEmail The email of the user. /// &lt;returns&gt;Drive service object.&lt;/returns&gt; static DriveService BuildService(String userEmail) { X509Certificate2 certificate = new X509Certificate2(SERVICE_ACCOUNT_PKCS12_FILE_PATH, "notasecret", X509KeyStorageFlags.Exportable); var provider = new AssertionFlowClient(GoogleAuthenticationServer.Description, certificate) { ServiceAccountId = SERVICE_ACCOUNT_EMAIL, Scope = DriveService.Scopes.Drive.GetStringValue(), ServiceAccountUser = userEmail, }; var auth = new OAuth2Authenticator&lt;AssertionFlowClient&gt;(provider, AssertionFlowClient.GetState); return new DriveService(auth); } } } </code></pre> <p>The error that I see is</p> <pre><code>(local variable) OAuth2Athenticator&lt;AssertionFlowClient&gt; auth Error: The best overloaded method match for 'Google.Apis.DriveService.DriveService(Googel.Apis.Services.BaseClientService.Initializer)' has some invalid arguments </code></pre> <p>This is my first time writing an app that uses Google's APIs and any help getting this working would be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload