scribe-node
Version:
Scribe java OAuth library port to node.js
21 lines (15 loc) • 933 B
text/coffeescript
scribe = require('./scribe').load(['GoogleApi'])
parser = require('xml2json').toJson
get_access_token = () ->\
token = '1%2FGHXMNTwHfevrSdV1qiAMzuyGUpp_5Tp2-3zn6H9gaZA'\
secret = '13eNR0DrNVM4i6CSpzLwCAaF'\
new scribe.Token token, secret
handle_analytics_accounts_feed = (response) ->\
console.log "Listing analytics account profiles:\n"\
entries = JSON.parse(parser(response.data)).feed.entry\
for entry in entries\
console.log entry.id + " " + entry.title['$t'] + " " + entry["dxp:tableId"]\
access_token = get_access_token()
analytics_accounts_feed = 'https://www.google.com/analytics/feeds/accounts/default?max-results=5'
service = new scribe.ServiceBuilder().provider(scribe.GoogleApi).apiKey('www.articlemanager.us').apiSecret('tD_FisW209w4ZRyE-ZoQwn8J')._scope('https://www.google.com/analytics/feeds/').build()
service.signedRequest(access_token, handle_analytics_accounts_feed, analytics_accounts_feed)