Skip to content

Commit

Permalink
Fixed OneDrive refreshing token, fixed handling of Google Drive inval…
Browse files Browse the repository at this point in the history
…id_grant error
  • Loading branch information
zenden2k committed May 13, 2024
1 parent fea11f9 commit 9571123
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Data/Scripts/googledrive.nut
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ function _CheckResponse(except = false) {
throw "unauthorized_exception";
}
return -2;
} else if (nm.responseCode() == 400) {
local t = ParseJSON(nm.responseBody());
if ("error" in t && t.error == "invalid_grant") {
_ClearAuthData();
return -2;
}
} else if (/*nm.responseCode() == 0 ||*/ (nm.responseCode() >= 400 && nm.responseCode() <= 499)) {
WriteLog("error", "Response code " + nm.responseCode() + "\r\n" + nm.errorString() );
return 0;
Expand Down
2 changes: 2 additions & 0 deletions Data/Scripts/onedrive.nut
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function RefreshToken() {
} catch ( ex ) {

}

refreshToken = ServerParams.getParam("refreshToken");
if ( time() > tokenTime + expiresIn && refreshToken != "") {
// Refresh access token
Expand All @@ -104,6 +105,7 @@ function RefreshToken() {
ServerParams.setParam("tokenType", tokenType);
ServerParams.setParam("token", token);
ServerParams.setParam("tokenTime", time().tostring());
ServerParams.setParam("refreshToken", t.refresh_token);
if ( token != "" ) {
return 1;
} else {
Expand Down

0 comments on commit 9571123

Please sign in to comment.