Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@
"message": "Sign in",
"description": "Sign in to 3rd party storage services"
},
"sign_in_business": {
"message": "Sign in (Business)",
"description": "Sign in to 3rd party storage services"
},
"onedrive_business_perms": {
"message": "Why do business accounts require more permissions?"
},
"log_out": {
"message": "Logout",
"description": "Sign out of 3rd party storage services"
Expand Down
10 changes: 8 additions & 2 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ function getBackupToken(service: string) {
redirUrl = encodeURIComponent(chrome.identity.getRedirectURL());
authUrl = `https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=${
getCredentials().onedrive.client_id
}&response_type=code&redirect_uri=${redirUrl}&scope=https%3A%2F%2Fgraph.microsoft.com%2FFiles.ReadWrite.AppFolder%20https%3A%2F%2Fgraph.microsoft.com%2FUser.Read%20offline_access&response_mode=query&prompt=consent`;
}&response_type=code&redirect_uri=${redirUrl}&scope=https%3A%2F%2Fgraph.microsoft.com%2FFiles.ReadWrite${
localStorage.oneDriveBusiness !== "true" ? ".AppFolder" : ""
}%20https%3A%2F%2Fgraph.microsoft.com%2FUser.Read%20offline_access&response_mode=query&prompt=consent`;
}
chrome.identity.launchWebAuthFlow(
{ url: authUrl, interactive: true },
Expand Down Expand Up @@ -459,7 +461,11 @@ function getBackupToken(service: string) {
xhr.send(
`client_id=${
getCredentials().onedrive.client_id
}&grant_type=authorization_code&scope=https%3A%2F%2Fgraph.microsoft.com%2FFiles.ReadWrite.AppFolder%20https%3A%2F%2Fgraph.microsoft.com%2FUser.Read%20offline_access&code=${value}&redirect_uri=${redirUrl}&client_secret=${encodeURIComponent(
}&grant_type=authorization_code&scope=https%3A%2F%2Fgraph.microsoft.com%2FFiles.ReadWrite${
localStorage.oneDriveBusiness !== "true"
? ".AppFolder"
: ""
}%20https%3A%2F%2Fgraph.microsoft.com%2FUser.Read%20offline_access&code=${value}&redirect_uri=${redirUrl}&client_secret=${encodeURIComponent(
getCredentials().onedrive.client_secret
)}`
);
Expand Down
11 changes: 10 additions & 1 deletion src/components/Popup/OneDrivePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
<a-button v-show="!backupToken" @click="getBackupToken()">
{{ i18n.sign_in }}
</a-button>
<a-button v-show="!backupToken" @click="getBackupToken(true)">
{{ i18n.sign_in_business }}
</a-button>
<div class="text" v-show="!backupToken">
<a href="https://authenticator.cc/docs/en/onedrive-perms">{{
i18n.onedrive_business_perms
}}</a>
</div>
<a-button v-show="backupToken" @click="backupUpload()">
{{ i18n.manual_dropbox }}
</a-button>
Expand Down Expand Up @@ -67,7 +75,8 @@ export default Vue.extend({
},
},
methods: {
getBackupToken() {
getBackupToken(business?: boolean) {
localStorage.oneDriveBusiness = Boolean(business);
chrome.runtime.sendMessage({ action: service });
},
async backupLogout() {
Expand Down
4 changes: 3 additions & 1 deletion src/models/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,9 @@ export class OneDrive implements BackupProvider {
localStorage.oneDriveRefreshToken
}&client_secret=${encodeURIComponent(
getCredentials().onedrive.client_secret
)}&grant_type=refresh_token&scope=https%3A%2F%2Fgraph.microsoft.com%2FFiles.ReadWrite.AppFolder%20https%3A%2F%2Fgraph.microsoft.com%2FUser.Read%20offline_access`
)}&grant_type=refresh_token&scope=https%3A%2F%2Fgraph.microsoft.com%2FFiles.ReadWrite${
localStorage.oneDriveBusiness !== "true" ? ".AppFolder" : ""
}%20https%3A%2F%2Fgraph.microsoft.com%2FUser.Read%20offline_access`
);
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/store/Backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Backup implements Module {
break;

case "onedrive":
state.driveToken = args.value;
state.oneDriveToken = args.value;
break;

default:
Expand Down