was amazing to copy my files from google dive to github with an apps script. until yesterday, something is changed in the google-world.
This is just a try to verify the github token key:
function verifyGitHubToken2() {
var token = 'GITHUB_TOKENold'; // Token di accesso GitHub
var url = '/';
var options = {
"method": "get",
"headers": {
"Authorization": "token " + token
}
};
try {
var response = UrlFetchApp.fetch(url, options);
Logger.log(response.getContentText());
} catch (e) {
Logger.log("Errore: " + e.message);
}
}
// Esegui questa funzione per verificare il tuo token GitHub
verifyGitHubToken2();
...but it leads to an error message:
Errore: Request failed for returned code 401. Truncated server response: {"message":"Bad credentials","documentation_url":";,"status":"401"} (use muteHttpExceptions option to examine full response)
The token is correct and is working since I verified with a shell command:
C:\Users\Dash>curl -H "Authorization: token *****************************"
I guess Google changed something! What could I try? Thanks a lot.
function listRepoContents() {
var userName = 'polvere73'; // Inserisci il tuo nome utente GitHub
var repoName = 'work'; // Inserisci il nome del repository
var token = 'GITHUB_TOKEN'; // Inserisci il tuo token di accesso personale
//var url = '/' + userName + '/' + repoName + '/contents/'; // URL API per elencare i contenuti del repository
var url = '/' + userName + '/' + repoName + '/contents/'; // URL API per elencare i contenuti del repository
var options = {
method: 'get',
muteHttpExceptions: true,
headers: {
Authorization: 'token ' + token
}
};
try {
var response = UrlFetchApp.fetch(url, options);
var data = JSON.parse(response.getContentText());
if (response.getResponseCode() === 200) {
Logger.log('File trovati nel repository:');
data.forEach(function(file) {
Logger.log(file.name);
});
} else {
Logger.log('Errore: ' + data.message);
}
} catch (e) {
Logger.log('Errore: ' + e.message);
}
}
I tried this code and leads to the message:
Errore Si è verificato un errore sconosciuto. Riprova più tardi
that means....An error occurred, try later! I Guess Google is driving me to use Google cloud storage instead of GitHub pages. that is very annoying
was amazing to copy my files from google dive to github with an apps script. until yesterday, something is changed in the google-world.
This is just a try to verify the github token key:
function verifyGitHubToken2() {
var token = 'GITHUB_TOKENold'; // Token di accesso GitHub
var url = 'https://api.github.com/repos/polvere73/work/HTML/';
var options = {
"method": "get",
"headers": {
"Authorization": "token " + token
}
};
try {
var response = UrlFetchApp.fetch(url, options);
Logger.log(response.getContentText());
} catch (e) {
Logger.log("Errore: " + e.message);
}
}
// Esegui questa funzione per verificare il tuo token GitHub
verifyGitHubToken2();
...but it leads to an error message:
Errore: Request failed for https://api.github.com returned code 401. Truncated server response: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"} (use muteHttpExceptions option to examine full response)
The token is correct and is working since I verified with a shell command:
C:\Users\Dash>curl -H "Authorization: token *****************************" https://api.github.com/repos/polvere73/work/contents/HTML
I guess Google changed something! What could I try? Thanks a lot.
function listRepoContents() {
var userName = 'polvere73'; // Inserisci il tuo nome utente GitHub
var repoName = 'work'; // Inserisci il nome del repository
var token = 'GITHUB_TOKEN'; // Inserisci il tuo token di accesso personale
//var url = 'https://api.github.com/repos/' + userName + '/' + repoName + '/contents/'; // URL API per elencare i contenuti del repository
var url = 'https://api.github.com/repos/' + userName + '/' + repoName + '/contents/'; // URL API per elencare i contenuti del repository
var options = {
method: 'get',
muteHttpExceptions: true,
headers: {
Authorization: 'token ' + token
}
};
try {
var response = UrlFetchApp.fetch(url, options);
var data = JSON.parse(response.getContentText());
if (response.getResponseCode() === 200) {
Logger.log('File trovati nel repository:');
data.forEach(function(file) {
Logger.log(file.name);
});
} else {
Logger.log('Errore: ' + data.message);
}
} catch (e) {
Logger.log('Errore: ' + e.message);
}
}
I tried this code and leads to the message:
Errore Si è verificato un errore sconosciuto. Riprova più tardi
that means....An error occurred, try later! I Guess Google is driving me to use Google cloud storage instead of GitHub pages. that is very annoying
Share Improve this question edited Jan 21 at 14:11 Davide Massi asked Jan 19 at 18:49 Davide MassiDavide Massi 213 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 0SOLVED: the system can't haldle the token as a variable outside the code
/
at the end. – TheMaster Commented Jan 19 at 21:35code 401 response
. – Lime Husky Commented Jan 20 at 16:04