Mattia
Mattia

Reputation: 329

Starting using Google Sheets API cannot get configuration/token files

I need to get access at the sheets and I am following this guide to start to do that https://developers.google.com/sheets/api/quickstart/nodejs

But the button that enables google APIs doesn't work, all names I put on the project return an error.

I went on the API console and created a new project but I do not know how to get credentials files (if they are needed) and then I must create an URL for the OAuth page?

Upvotes: 0

Views: 125

Answers (1)

ziganotschka
ziganotschka

Reputation: 26796

How to get OAuth crendetials manually

  • There different types of crendetials and the procedure to obtain them is slightly different depending on your situation.See here for the different scenarios.

  • In most cases (an exception is when using a service account), the first step is to set up an OAuth consent screen.

  • The consent screen is the screen your users see when they are prompted to agree to terms that are presented to them by your application

  • To set up a OAuth consent screen, go after chosing a project from the GCP console on APIs & services -> OAuth consent screen

  • You need to chose either your application is supposed to accessible only by domain internal users or also external (in the latter case you might need to submit your application for verification by Google, pontentially involving costs - depending on the scopes you use).

  • You need to provide an application name that your users will see (the logo is optional)

  • You need to specify which scopes your app will use

  • You can specify other properties, e.g. the Authorized domains (this is usually your website from which the users will be redirected to the consent screen when performaing some kind of action)

  • If you are not sure about the optional properties, leave them out for the start


  • Once you set up the authentication screen, the second step is to go on APIs & services -> Credentials
  • Read the Authentication overview to decide which credentials you need
  • For most applications you will want an OAuth client ID
  • The diffrent Application types are described here, to start with create a Web Application
  • Authorized JavaScript origins and Authorized redirect URIs is basically your Webpage from which the users will be redirected to authenticate and to which they should be redirected after authentication.
  • For local testing you do not need to specify those URLs
  • Once you create the OAuth2 client successfully, you will obtain the Client ID and Client Secret - your crendetials to incorporate into your code when using Google APIs.
  • If you click on the download button on the right side of your newly created credentials - it will generate a json file on your local machine from which the credentials will be read automatically if you follow the quickstart.
  • Alternatively you can paste the credentials directly into your code - see here for sample for different situations

Upvotes: 1

Related Questions