Here is what I've accomplished so far. I removed my consumer/secret obviously:
function makeRequest() {
var fsService = getFatSecretService();
}
function getFatSecretService() {
// Create a new service with the given name. The name will be used when
// persisting the authorized token, so ensure it is unique within the
// scope of the property store.
return OAuth1.createService('fatsecret')
// Set the endpoint URLs.
// Set the consumer key and secret.
.setConsumerKey('****')
.setConsumerSecret('****')
// Set the name of the callback function in the script referenced
// above that should be invoked to complete the OAuth flow.
.setCallbackFunction('authCallback')
// Set the property store where authorized tokens should be persisted.
.setPropertyStore(PropertiesService.getUserProperties());
}
function showSidebar() {
var fsService = getFatSecretService();
if (!fsService.hasAccess()) {
var authorizationUrl = fsService.authorize();
var template = HtmlService.createTemplate(
'<a href="<?= authorizationUrl ?>" target="_blank">Authorize</a>. ' +
'Reopen the sidebar when the authorization is complete.');
template.authorizationUrl = authorizationUrl;
var page = template.evaluate();
DocumentApp.getUi().showSidebar(page);
} else {
}
}
function authCallback(request) {
var fsService = getFatSecretService();
var isAuthorized = fsService.handleCallback(request);
if (isAuthorized) {
return HtmlService.createHtmlOutput('Success! You can close this tab.');
} else {
return HtmlService.createHtmlOutput('Denied. You can close this tab');
}
}
Any help on where I'm going wrong would be greatly appreciated. :D