googleworkspace / node-samples

Node samples for Google Workspace APIs.
Apache License 2.0
467 stars 488 forks source link

Authorization code is not showing up in authorization flow #95

Open bedefrunner opened 4 years ago

bedefrunner commented 4 years ago

Expected Behavior

After following the link printed in the console when doing the quickstart, an authorization code should appear so I can copy-paste it in my console.

Actual Behavior

I can access the link, which guides me through the following steps:

  1. It asks me to select one of my gmails accounts.
  2. Then it shows "This app isn't verified", so I click Advanced > Go to {Project Name}
  3. A pop up asks to give permission to the app to my account's calendar, I select "allow"
  4. Then it asks me to confirm my options. I click on "allow"
  5. It redirects me to my app's landing page

Where is the code I should see to copy and paste into my console?

Specifications

bedefrunner commented 4 years ago

Solved. The problem was that the first step that the API asks you for in its official tutorial is to click on the "Enable Google Calendar API" button, where it asks you to write the URL of your web server. The description says: "this is the path in your application that users are redirected to after they have authenticated with Google. The path will be appended with the authorization code for access". The problem was that I wrote the home path of my application myapp.com/, but my application never "stays" in that path but automatically redirects to myapp/sessions/login, so the code for access was "lost". Now that I changed the path to miapp/sessions/login I could see the code appended to that path.

Lathryx commented 3 years ago

Solved. The problem was that the first step that the API asks you for in its official tutorial is to click on the "Enable Google Calendar API" button, where it asks you to write the URL of your web server. The description says: "this is the path in your application that users are redirected to after they have authenticated with Google. The path will be appended with the authorization code for access". The problem was that I wrote the home path of my application myapp.com/, but my application never "stays" in that path but automatically redirects to myapp/sessions/login, so the code for access was "lost". Now that I changed the path to miapp/sessions/login I could see the code appended to that path.

To clarify, when you go through the authorization process and reach the URI callback (mine was simply https://google.com), the code will be held as the first parameter in the URL. For example, my URL would be something like this:

https://www.google.com/?code={CODE WILL BE HERE}&scope.......

Simply copy the space labeled {CODE WILL BE HERE} in the above line. Once authorized, a file named token.json should be created and automatically used from that point on.