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

Clean-ups for 0.4.7 #116

Merged
merged 7 commits into from
Dec 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ googleapis
var req1 = client.urlshortener.url.get({ shortUrl: 'http://goo.gl/DdUKX' });

// example request designed to return an error
var req2 = client.urlshortener.url.get({ shortUrl: 'http://goo.gl/DdUdX' });
var req2 = client.urlshortener.url.get({ shortUrl: 'http://goo.gl/DdUKX' });

//build a batch request and execute
client.newBatchRequest()
Expand All @@ -32,10 +32,10 @@ googleapis
.execute(function(err, results) {
if (err) {
console.log("Error", err);
return
return;
}
results.forEach(function(i, v) {
console.log('Response longUrl #', i + 1, ':', v);
results.forEach(function(result) {
console.log('Response longUrl #', result);
});
});
});
4 changes: 2 additions & 2 deletions examples/mediaupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
var googleapis = require('../lib/googleapis.js');

var auth = new googleapis.OAuth2Client();
auth.credentials = {
auth.setCredentials({
access_token: 'ACCESS TOKEN HERE'
};
});

googleapis.discover('drive', 'v2').execute(function(err, client) {

Expand Down
11 changes: 6 additions & 5 deletions examples/multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ var googleapis = require('../lib/googleapis.js');
// PUT your API key here or this example will return errors
// To learn more about API keys, please see:
// https://developers.google.com/console/help/#UsingKeys
var API_KEY = 'YOUR API KEY HERE';
var API_KEY = 'AIzaSyBzQOyq8uKZKMTRfEPP-Qbrmy98CopcZRY';

googleapis
.discover('urlshortener', 'v1')
.discover('plus', 'v1')
.execute(function(err, client) {
var req1 = client.urlshortener.url.get({ shortUrl: 'http://goo.gl/DdUKX' });
var req2 = client.plus.people.get({ userId: '+BurcuDogan' });
req1.withApiKey(API_KEY).execute()
req2.withApiKey(API_KEY).execute()
client
.urlshortener.url.get({ shortUrl: 'http://goo.gl/DdUKX' })
.withApiKey(API_KEY).execute();
client.plus.people.get({ userId: '+burcudogan' })
.withApiKey(API_KEY).execute();
});
24 changes: 10 additions & 14 deletions examples/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,18 @@ var rl = readline.createInterface({
function getAccessToken(oauth2Client, callback) {
// generate consent page url
var url = oauth2Client.generateAuthUrl({
access_type: 'offline',
access_type: 'offline', // will return a refresh token
scope: 'https://www.googleapis.com/auth/plus.me'
});

console.log('Visit the url: ', url);
rl.question('Enter the code here:', function(code) {

// request access token
oauth2Client.getToken(code, function(err, tokens) {
// set tokens to the client
// TODO: tokens should be set by OAuth2 client.
oauth2Client.credentials = tokens;
callback && callback();
oauth2Client.setCredentials(tokens);
callback();
});
});
}
Expand All @@ -57,14 +56,6 @@ function getUserProfile(client, authClient, userId, callback) {
.execute(callback);
}

function printUserProfile(err, profile) {
if (err) {
console.log('An error occurred');
} else {
console.log(profile.displayName, ':', profile.tagline);
}
}

// load google plus v1 API resources and methods
googleapis
.discover('plus', 'v1')
Expand All @@ -76,8 +67,13 @@ googleapis
// retrieve an access token
getAccessToken(oauth2Client, function() {
// retrieve user profile
getUserProfile(
client, oauth2Client, 'me', printUserProfile);
getUserProfile(client, oauth2Client, 'me', function(err, profile) {
if (err) {
console.log('An error occured', err);
return;
}
console.log(profile.displayName, ':', profile.tagline);
});
});

});
3 changes: 2 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Client.prototype.generateHelper_ = function(methodMeta) {
/**
* Constructs a request to method with given parameters.
*
* @param {string} methodName Full name of the method.
* @param {object} methodMetada Discovery metadata of the method.
* @param {?object} params Parameters.
* @param {object=} opt_resource Optional resource.
*
Expand Down Expand Up @@ -103,6 +103,7 @@ Client.prototype.withDefaultParams = function(params) {
};

/**
* @private
* Extends the object with the given resource and its methods
* recursively.
* @param {?object} root Object to be extended.
Expand Down
Loading