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

Express example? #263

Closed
newz2000 opened this issue Aug 27, 2014 · 7 comments
Closed

Express example? #263

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

Comments

@newz2000
Copy link

Hello, I've gotten the example code working but going from essentially "hello world" to being able to use this in a web app has proven too much of a challenge.

I've also searched the web for example apps using Express and google-api-nodejs-client and come up with nothing useful.

I'd really love for an example where you can view an app's home page, click an authorize/login button and view some information specific to that user. For example, view the last five files the user uploaded or last few posts to Google+ or similar.

Really, anything is useful. I've gotten apps working with Passport authentication, but that is different than authorizing an app to to use a Google API on the user's behalf.

Does anyone have time to document or create an example app that does this?

@ryanseys
Copy link
Contributor

The following example I made is really out of date but might give you a good starting point... In theory it used to work though it might require some tweaking to work now.

See it here: https://github.com/ryanseys/google-api-test-app

@ryanseys
Copy link
Contributor

@newz2000 Let me know if this helps or if you have any other questions. I will be happy to help!

@newz2000
Copy link
Author

newz2000 commented Sep 3, 2014

@ryanseys thanks, it is helpful. I'm still working on getting it working, but it's a big nudge in the right direction.

Sadly, my life is made complicated by being behind a proxy. I am going to try the code at home if I don't get it going at work, but for now I'm trying this (so far unsuccessfully) in routes/index.js:

if(process.env.http_proxy) {
  google.options({ proxy: process.env.http_proxy});
  console.log('Setting a proxy');
}

I'll post details once I get it working.

@newz2000
Copy link
Author

newz2000 commented Sep 5, 2014

I've got it working, thanks! There are problems when working behind a proxy, I'll work them out later if I can and file a ticket if applicable. This example works pretty good. The only changes I had to make where adding the googleapis module to package.json and updating the require statement in routes/index.js and then updating app.use(session...) to get rid of some deprecation errors.

index 3a2376f..5e5eae7 100644
--- a/app.js
+++ b/app.js
@@ -19,7 +19,7 @@ app.use(logger('dev'));
 app.use(bodyParser.json());
 app.use(bodyParser.urlencoded());
 app.use(cookieParser());
-app.use(session({secret: 'keyboard cat'}))
+app.use(session({secret: 'keyboard cat', resave: true, saveUninitialized: false}))
 app.use(express.static(path.join(__dirname, 'public')));

 app.use('/', routes);

@newz2000 newz2000 closed this as completed Sep 5, 2014
@ryanseys
Copy link
Contributor

ryanseys commented Sep 5, 2014

Sweet! Thanks for the update, I'll file an issue on my repo and make the appropriate changes when I have time.

@newz2000
Copy link
Author

newz2000 commented Sep 5, 2014

Or maybe I can propose a change. I have the diff right here... :-)

@ryanseys
Copy link
Contributor

ryanseys commented Sep 5, 2014

Do it up! 😄

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
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

3 participants