Add: revoke dropbox token
This commit is contained in:
parent
0d3f0540ed
commit
acd23d7162
|
@ -9,7 +9,14 @@ const tokenManager = (() => {
|
||||||
flow: 'token',
|
flow: 'token',
|
||||||
clientId: 'zg52vphuapvpng9',
|
clientId: 'zg52vphuapvpng9',
|
||||||
authURL: 'https://www.dropbox.com/oauth2/authorize',
|
authURL: 'https://www.dropbox.com/oauth2/authorize',
|
||||||
tokenURL: 'https://api.dropboxapi.com/oauth2/token'
|
tokenURL: 'https://api.dropboxapi.com/oauth2/token',
|
||||||
|
revoke: token =>
|
||||||
|
fetch('https://api.dropboxapi.com/2/auth/token/revoke', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${token}`
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
google: {
|
google: {
|
||||||
flow: 'code',
|
flow: 'code',
|
||||||
|
@ -22,8 +29,11 @@ const tokenManager = (() => {
|
||||||
access_type: 'offline'
|
access_type: 'offline'
|
||||||
},
|
},
|
||||||
tokenURL: 'https://oauth2.googleapis.com/token',
|
tokenURL: 'https://oauth2.googleapis.com/token',
|
||||||
revokeURL: 'https://accounts.google.com/o/oauth2/revoke',
|
scopes: ['https://www.googleapis.com/auth/drive.appdata'],
|
||||||
scopes: ['https://www.googleapis.com/auth/drive.appdata']
|
revoke: token => {
|
||||||
|
const params = {token};
|
||||||
|
return postQuery(`https://accounts.google.com/o/oauth2/revoke?${stringifyQuery(params)}`);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onedrive: {
|
onedrive: {
|
||||||
flow: 'code',
|
flow: 'code',
|
||||||
|
@ -72,16 +82,12 @@ const tokenManager = (() => {
|
||||||
.then(() => chromeLocal.remove(k.LIST));
|
.then(() => chromeLocal.remove(k.LIST));
|
||||||
|
|
||||||
function revoke() {
|
function revoke() {
|
||||||
if (!provider.revokeURL) {
|
if (!provider.revoke) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
return chromeLocal.get(k.TOKEN)
|
return chromeLocal.get(k.TOKEN)
|
||||||
.then(obj => {
|
.then(obj => provider.revoke(obj[k.TOKEN]))
|
||||||
const params = {
|
.catch(console.error);
|
||||||
token: obj[k.TOKEN]
|
|
||||||
};
|
|
||||||
return postQuery(`${provider.revokeURL}?${stringifyQuery(params)}`);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user