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

appsactivity.activities.list with jwt auth always returns 400 #356

Closed
skhavari opened this issue Jan 30, 2015 · 2 comments
Closed

appsactivity.activities.list with jwt auth always returns 400 #356

skhavari opened this issue Jan 30, 2015 · 2 comments
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@skhavari
Copy link

Repro

Run the sample code below

Expect

It to output the users activity list for their top level google drive folder

Actual

Always returns 400

var google = require('googleapis');
var appsActivities = google.appsactivity('v1');
var util = require('util');

var jwtClient = new google.auth.JWT(
  '<email>',
  './key.pem',
  null,
  [ "https://www.googleapis.com/auth/activity",
    "https://www.googleapis.com/auth/admin.reports.audit.readonly",
    "https://www.googleapis.com/auth/admin.reports.usage.readonly", 
    "https://www.googleapis.com/auth/drive"],
  '<user-email-addr>');

jwtClient.authorize(function(err, tokens) {
  if (err) {
    log(err);
    return;
  }

  appsActivities.activities.list( {auth: jwtClient, userId: "me"}, function(err, resp){
    log(err);
    log(resp);
  });
});

function log(object){
  console.log(util.inspect(object, {showHidden: false, depth: null}));
}
@ryanseys
Copy link
Contributor

You cannot use a JWT to authorize these Google Apps Activity requests, you must use OAuth 2.0. See here for more information.

This is because JWT essentially authenticates to Google as a new user, not as an existing user. Because of this, there's no way the JWT has access to any user data or user-facing features such as Google Apps, including all the data for yourself. Another good example of this is in #347.

Please use OAuth 2.0 and let me know how that works out.

@skhavari
Copy link
Author

skhavari commented Feb 4, 2015

rock n roll!

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