<commit_before>var Dwolla = require('dwolla')(cfg.apiKey, cfg.apiSecret)   // Include the Dwolla REST Client
    , cfg = require('./_config')                            // Include any required keys
    , $ = require('seq')
    , express = require('express')
    , app = express()
    ;

// Some constants...
var redirect_uri = 'http://localhost:3000/oauth_return'


/**
 * STEP 1: 
 *   Create an authentication URL
 *   that the user will be redirected to
 **/
app.get('/', function(req, res) {
    var authUrl = Dwolla.authUrl(redirect_uri);

    return res.send('To begin the OAuth process, send the user off to <a href="' + authUrl + '">' + authUrl + '</a>');
});


/**
 * STEP 2:
 *   Exchange the temporary code given
 *   to us in the querystring, for
 *   a never-expiring OAuth access token
 **/
app.get('/oauth_return', function(req, res) {
    var code = req.query['code'];

    Dwolla.requestToken(code, redirect_uri, function(error, token) {
        return res.send("Your never-expiring OAuth access token is: <b>" + token + "</b>");
    });
});


// Start the server
app.listen(3000);<commit_msg>update OAuth example to show refresh token functionality<commit_after>var cfg = require('./_config'); // require any needed keys
var Dwolla = require('dwolla')(cfg.apiKey, cfg.apiSecret); // initialize API client
var $ = require('seq');
var express = require('express');
var app = express();

// Some constants...
var redirect_uri = 'http://localhost:3000/oauth_return';

// use sandbox API environment
Dwolla.sandbox = true;


/**
 * STEP 1: 
 *   Create an authentication URL
 *   that the user will be redirected to
 * 
 *   Visit http://localhost:3000/ to see it in action.
 **/
app.get('/', function(req, res) {
    var authUrl = Dwolla.authUrl(redirect_uri);

    return res.send('To begin the OAuth process, send the user off to <a href="' + authUrl + '">' + authUrl + '</a>');
});


/**
 * STEP 2:
 *   Exchange the temporary code given
 *   to us in the querystring, for
 *   a never-expiring OAuth access token
 **/
app.get('/oauth_return', function(req, res) {
    var code = req.query.code;

    Dwolla.finishAuth(code, redirect_uri, function(error, auth) {
        var output = "Your OAuth access_token is: <b>" + auth.access_token + "</b>, which will expire in " + auth.expires_in + " seconds.<br>Your refresh_token is: <b>" + auth.refresh_token + "</b>, and that'll expire in " + auth.refresh_expires_in + " seconds.";
        output += '<br><a href="/refresh?refreshToken=' + auth.refresh_token + '">Click here to get a new access and refresh token pair!</a>';
        return res.send(output);
    });
});

app.get('/refresh', function(req, res) {
    Dwolla.refreshAuth(req.query.refreshToken, function(error, auth) {
        var output = "Your OAuth access_token is: <b>" + auth.access_token + "</b>, which will expire in " + auth.expires_in + " seconds.<br>Your refresh_token is: <b>" + auth.refresh_token + "</b>, and that'll expire in " + auth.refresh_expires_in + " seconds.";
        output += '<br><a href="/refresh?refreshToken=' + auth.refresh_token + '">Click here to get a new access and refresh token pair!</a>';
        return res.send(output);
    });
});


// Start the server
app.listen(3000);
{'fraction_non_alphanumeric': 0.1572929542645241, 'fraction_numerical': 0.007416563658838072, 'mean_word_length': 3.3275401069518717, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2709809', 'n_tokens_mistral': 1057, 'n_tokens_neox': 994, 'n_words': 307}