1

I'm working on a Node.js application that uses Passport.js for authenticating with Google Plus. In a later stage now, we have introduced of adding activities using Google+'s moment.insert to the user's Google+ feed when they leave reviews at our site. Posting using moment.insert needs a special permission called requestvisibleactions. The passport.js documentation doesn't say how I can ask for such permissions while logging in.

My current auth handler setup is like this:

app.get('/auth/google', redirect, passport.authenticate('google', {
    scope: ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/plus.moments.write'],
    accessType: 'offline'
}));

Any pointers on how I can specify the requestvisibleactions permission mentioned in this page during passport.js authentication is appreciated.

Sparky
  • 4,769
  • 8
  • 37
  • 52

1 Answers1

2

The problem is that passport.js doesn't include support for requestvisibleactions, and the pull request to update it has been sitting there for a while. As we discussed on Google+ insert moment with nodejs client You will need to do two things:

1) Apply this patch, which lets passport.js be able to set the parameter correctly.

2) Set the action that you wish to be able to do as part of the call to passport.authenticate

I have not tested this (since I don't use passport.js), but once you have done (1), you should be able to use something like this to be able to post Add and Review moments:

app.get('/auth/google', redirect, passport.authenticate('google', {
    scope: ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/plus.moments.write'],
    accessType: 'offline',
    requestVisibleActions: 'http://schema.org/AddAction http://schema.org/ReviewAction'
}));
Community
  • 1
  • 1
Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • i just have accesType and requestVisibleActions , but not work ? And try use google api explorer , request sent but nothing in my google plus activity, why ?? where is i can find the post?? – masadi zainul Feb 09 '15 at 08:50
  • @masadizainul - It sounds like you should post this as a separate question, with illustrative code, so we can help figure out whats going on. – Prisoner Feb 09 '15 at 10:20