-
Notifications
You must be signed in to change notification settings - Fork 38
Home
excode edited this page Nov 7, 2019
·
1 revision
``var {google} = require('googleapis');
var MESSAGING_SCOPE = "https://www.googleapis.com/auth/firebase.messaging";`
`var SCOPES = [MESSAGING_SCOPE];`
var http = require('http')
function getAccessToken(){
return new Promise(function(resolve, reject){
var key = require("./ServiceAccountKey.json");
var jwtClient = new google.auth.JWT(
key.client_email,
null,
key.private_key,
SCOPES,
null
);
jwtClient.authorize(function(err, tokens){
if(err){
reject(err);
return;
}
resolve(tokens.access_token+":"+tokens.expiry_date);
});
});
}
var server = http.createServer(function(req, res){
`getAccessToken().then(function(access_token){`
`res.end(access_token);`
`});`
});
server.listen(3000, function(){
console.log("Server started");
});
I want to fetch Google Oauth Token . THe above NodeJs code is working but I need an ERLANG version, IS there anybody who can guide me or give me instruction so that I can fetch Google Oauth Token usinng ERLANG.
Thanks in advance.