Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to load client_secret JSON ? #266

Closed
timcash opened this issue Aug 29, 2014 · 9 comments
Closed

Possible to load client_secret JSON ? #266

timcash opened this issue Aug 29, 2014 · 9 comments
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@timcash
Copy link

timcash commented Aug 29, 2014

1.) Instead of setting the clientid secret and redirect manually is it possible to load the JSON file one can download from the Developer Console?

2.) Is there a list somewhere of what scopes are need for each service? I am having trouble getting the compute api to work. Could the apis load the scopes needed implicitly?

3.) Just to make sure, I need to use the Oauth2 "installed application" option for this api correct?

@rakyll
Copy link
Contributor

rakyll commented Aug 29, 2014

Instead of setting the clientid secret and redirect manually is it possible to load the JSON file one can download from the Developer Console?

Are you talking about JSON key file for service accounts? If so, currently the answer is no.

2.) Is there a list somewhere of what scopes are need for each service?

Each API documents its own requirements for scopes. You can take a look at https://developers.google.com/oauthplayground/ for reference though.

3.) Just to make sure, I need to use the Oauth2 "installed application" option for this api correct?

We support OAuth 2.0 web server, installed apps and service accounts flows. Which one are you planning to use?

@timcash
Copy link
Author

timcash commented Aug 29, 2014

I am building a web app so we can manage our cluster. I was thinking I would set up a GCE instance with a node.js server and have that server run all the commands. I could let our developers log into that server using Oauth2. So a Client ID for web application is what I would need I think from looking at all the Oauth docs. Is there an example of using "service accounts flows" ? how would I use that? From looking at the python api that would allow me to use my own login system correct?

I have attempted to use the example
https://github.com/google/google-api-nodejs-client/blob/master/examples/oauth2.js

made a few modification to try to use with compute engine like so
https://gist.github.com/timcash/ec3a76708ef021102efb

I then run with node, login at the url provided , allow access to "offline", copy paste the code returned in the url (looks like "4/Y2x...."). I then get the response

An error occured { errors:
[ { domain: 'global',
reason: 'required',
message: 'Login Required',
locationType: 'header',
location: 'Authorization' } ],
code: 401,
message: 'Login Required' }

I was able to use the python api here (with a "service account" and JSON key) without a problem and it correctly lists my instances
https://developers.google.com/compute/docs/api/python-guide#listinginstances

I can also successfully use the api explorer.
https://developers.google.com/apis-explorer/#p/compute/v1/compute.instances.list

@rainabba
Copy link

This is days in the works, but will hopefully help clear a thing or two up. "google-api-nodejs-client examples using JWT and service account" https://gist.github.com/rainabba/25d1972f455b71916952

@sarlv
Copy link

sarlv commented Apr 10, 2016

@JustinBeckwith
Copy link
Contributor

Greetings! The docs here have improved a great deal over the last looks down 4 years. If this is still an issue - feel free to open a new bug!

@rainabba
Copy link

rainabba commented May 9, 2018

Updated after my 3rd attempt in 2 years to get Drive support in my node app, but being thwarted by volumes of confusing documents, conflicting examples and various approaches. As of 2018-05-09, this approach is "current" in that is uses the latest approach from the console, but it uses API v25 because v29 breaks completely with these samples and I can't find any docs that address those issues.

Here's my updated gist that requires a client_secret.json, will provide a URL, take the code and save a .token file next to the source .json. It uses the Nodejs debugger to halt code and get the code value in the debugger because I was having issues that made me leary about the console and the debugger works so well anyway :)

https://gist.github.com/rainabba/25d1972f455b71916952

@JustinBeckwith
Copy link
Contributor

@rainabba sorry to hear you've had so much trouble. Can you share an example of a broken sample with v29? I'd love to fix it. Everything in here should be working :)

@rainabba
Copy link

rainabba commented May 9, 2018

This explains that particular challenge: #1158

I was so caught up in the keys for a while that I'd missed the obvious. That code is what got me as far as the above gist btw. With it I learned the flow and rebuilt it.

Now that I FINALLY have a token, it's time to see if I can do what I've set out to, saving PDFs directly to Drive.

@rainabba
Copy link

Just over a month later and I've finally released node-cloudfs-drive: https://www.npmjs.com/package/node-cloudfs-drive

Hopefully this will fill the gap I see at least 10 other projects trying to do (or had tried in the past) and I intend to maintain this for at least a couple years unless Google finally pushes me over the edge with more anti-enterprise behavior on Drive (like not letting me install Drive File Stream on a server, or throttling my API calls so that I can't have a properly optimized lookup system with our 100,000's of objects we maintain there). That's another convo though :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

6 participants