I'd like insert account my google glass, but I cann't do that.
I'm using node.js(v0.10.31), googleapis(v1.0.11) and passport-google-oauth(v0.1.5)
of course, I turned on Google Mirror API on Google Developers Console. and made pem file.
Here is google Developers console setting. (I tried to upload pics but, I need some levels.)
pkginfo.oauth.google
CLIENT ID 670282105???-a???pbnh1pp.apps.googleusercontent.com
EMAIL ADDRESS 670282105???-????nh1pp@developer.gserviceaccount.com
CLIENT SECRET jt0WiP???pCwXT
REDIRECT URIS http://www.-----------.com:3333/auth/google/callback
JAVASCRIPT ORIGINS http://www.-----------.com:3333
http://www.-----------.com
https://mirror-api-playground.appspot.com
.
pkginfo.oauth.glass
CLIENT ID 67028????qjv.apps.googleusercontent.com
EMAIL ADDRESS 6702821053????qjv@developer.gserviceaccount.com
PUBLIC KEY
FINGERPRINTS e25e3a045????a4e40 – Delete
822e7bda????e85c56 – Delete
70ae6e7c????45c7c9 – Delete
Here are my codes.
passport.use(new GoogleStrategy({
clientID: pkginfo.oauth.google.CLIENT_ID,
clientSecret: pkginfo.oauth.google.CLIENT_SECRET,
callbackURL: pkginfo.oauth.google.REDIRECT_URL
},
function(accessToken, refreshToken, profile, done) {
var googleapis = require('googleapis');
var mirror = googleapis.mirror('v1');
var OAuth2 = googleapis.auth.OAuth2;
var jwt = new googleapis.auth.JWT(pkginfo.oauth.glass.EMAIL_ADDRESS,
pkginfo.oauth.glass.KEY_FILE,
null,//'notasecret',
['https://www.googleapis.com/auth/glass.thirdpartyauth'],
null);
jwt.authorize(function(err, tokens) {
if (err) clog.error("Error @jwt.authorize:" + err);
var oAuth2Client = new OAuth2(pkginfo.oauth.google.CLIENT_ID,
pkginfo.oauth.google.CLIENT_SECRET,
'postmessage');
oAuth2Client.setCredentials({
access_token : tokens.access_token
})
var params = {
auth: oAuth2Client,
userToken : accessToken,
accountType : "com.cocoa.glasshelpme",
accountName : profile.emails[0].value,
resource :
{
features: ["a", "b", "c"],
userData: [
{key : "realName" , value : "James jerry"}
],
authTokens: [
{ type: tokens.token_type, authToken: accessToken }
]
}
};
mirror.accounts.insert(params, callback);
function callback(err,result) {
clog.error(err);
clog.debug(result);
};
and I got this error message.
error: { errors: [ { domain: 'global', reason: 'invalid', message: 'Invalid Value' } ],
code: 400,
message: 'Invalid Value' }
Thank you.