Dibyendu Roy
Dibyendu Roy

Reputation: 103

RingCentral Glip Bot OAuth

What is the new way/method to implement OAuth for Glip Bot Apps in RingCentral Platform? (RingCentral Developer portal now has a way to get a permanent access token for Glip Bot Apps)

app.get('/oauth', function (req, res) {
    if(!req.query.code){
        res.status(500);
        res.send({"Error": "Looks like we're not getting code."});
        console.log("Looks like we're not getting code.");
    }else {
        platform.login({
            code : req.query.code,
            redirectUri : REDIRECT_HOST + '/oauth'
        }).then(function(authResponse){
            var obj = authResponse.json();
            bot_token = obj.access_token;
            console.log(obj);
            console.log(bot_token);
            res.send(obj)
            subscribeToGlipEvents();
        }).catch(function(e){
            console.error(e)
            res.send("Error: " + e);
        })
    }
});

Upvotes: 0

Views: 93

Answers (1)

Dibyendu Roy
Dibyendu Roy

Reputation: 103

The new method would be using POST instead of get as seen below

app.post('/oauth', function(req, res){
    var token = req.body.access_token;
    creatorID = req.body.creator_extension_id; 
    console.log(token);
    res.send({});
    var data = platform.auth().data();
    data.token_type = "bearer"
    data.expires_in = 500000000
    data.access_token = token
    platform.auth().setData(data)
    getBotIdentity();
});

Upvotes: 0

Related Questions