This is an old documentation. Go to the latest Customer's Canvas docs

User Accounts

This topic describes how you can obtain a private key and an access token to allow your users to work with your Google Drive assets.

Getting a Private Key

To get a key for a user account

  1. Click to create a project in the Google Developers Console and automatically turn on the API. On the following page, click Continue.

    Registering an application in Google API Console.

    When the confirmation page appears, click Go to credentials.
  2. On the Add credentials to your project page, click the Cancel button.
  3. At the top of the page, click the OAuth consent screen tab. Select an Email address, enter a Product name if it's not already set, and then click Save.

    Adding API credentials.

  4. Click the Credentials tab, click the Create credentials button, and then select OAuth client ID.
  5. Select the application type Other, enter the name "Drive API", and then click Create.

    Creating OAuth client ID.

  6. Click OK to dismiss the resulting dialog.
  7. Click the Download button.

    Downloading a key.

  8. Move the downloaded file to your working directory and rename it as client_secret.json.

Getting a Google Access Token

The Google Drive web service uses Google Access Tokens to work under user accounts.

Prior to the token generation, you need to specify paths to your client key and an output token file in gdtokengen.exe.config.

        <add key="OAuthClientSecretPath" value="client_secret.json" />
        <add key="OAuthClientCredentialPath" value="" />

In this example, the OAuthClientSecretPath parameter defines the location of the OAuth Client (the client_secret.json file) in the same folder where you unzipped this console application to. If OAuthClientCredentialPath is an empty string, then a token file will be created in the folder specified in OAuthClientSecretPath.

To generate a token:

  1. Run gdtokengen.exe.
  2. Sign in to your Google account.
  3. Click Allow.

    Confirming access to a Google account.

  4. Press any key to close the application.
  5. Verify that the Google.Apis.Auth.OAuth2.Responses.TokenResponse-CustomersCanvas token file has appeared in your OAuthClientCredentialPath folder.

See Also