MCPcopy Create free account
hub / github.com/CloudBoost/cloudboost / getUserByTokens

Function getUserByTokens

helpers/google.js:108–142  ·  view source on GitHub ↗
(req, appId, authSettings, accessToken, refreshToken)

Source from the content-addressed store, hash-verified

106
107
108 getUserByTokens(req, appId, authSettings, accessToken, refreshToken) {
109 const deferred = q.defer();
110
111 try {
112 const clientId = authSettings.google.appId;
113 const clientSecret = authSettings.google.appSecret;
114 const redirect = `${req.protocol}://${req.headers.host}/auth/${appId}/google/callback`;
115
116 const oauth2Client = new OAuth2Client(clientId, clientSecret, redirect);
117
118 oauth2Client.setCredentials({
119 access_token: accessToken,
120 refresh_token: refreshToken,
121 });
122
123 plus.people.get({
124 userId: 'me',
125 auth: oauth2Client,
126 }, (err, profile) => {
127 if (err) {
128 deferred.reject(err);
129 } else {
130 deferred.resolve(profile);
131 }
132 });
133 } catch (err) {
134 winston.log('error', {
135 error: String(err),
136 stack: new Error().stack,
137 });
138 deferred.reject(err);
139 }
140
141 return deferred.promise;
142 },
143};

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected