mirror of
https://github.com/jiojciojsioe3/a3cjroijsiojiorj.git
synced 2024-11-15 07:21:50 +08:00
Merge pull request #440 from bui/gpicker-api-changes
Gpicker API Changes
This commit is contained in:
commit
84b4bf00a8
@ -313,8 +313,10 @@ class CustomSongs{
|
|||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
|
if(this.linkGdriveAccount){
|
||||||
var addRemove = !gpicker || !gpicker.oauthToken ? "add" : "remove"
|
var addRemove = !gpicker || !gpicker.oauthToken ? "add" : "remove"
|
||||||
this.linkGdriveAccount.classList[addRemove]("hiddenbtn")
|
this.linkGdriveAccount.classList[addRemove]("hiddenbtn")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
gdriveAccount(event){
|
gdriveAccount(event){
|
||||||
@ -514,6 +516,9 @@ class CustomSongs{
|
|||||||
pageEvents.remove(document, ["dragover", "dragleave", "drop"])
|
pageEvents.remove(document, ["dragover", "dragleave", "drop"])
|
||||||
delete this.dropzone
|
delete this.dropzone
|
||||||
}
|
}
|
||||||
|
if(gpicker){
|
||||||
|
gpicker.tokenResolve = null
|
||||||
|
}
|
||||||
delete this.browse
|
delete this.browse
|
||||||
delete this.linkLocalFolder
|
delete this.linkLocalFolder
|
||||||
delete this.linkGdriveFolder
|
delete this.linkGdriveFolder
|
||||||
|
@ -11,6 +11,7 @@ class Gpicker{
|
|||||||
this.filesUrl = "https://www.googleapis.com/drive/v3/files/"
|
this.filesUrl = "https://www.googleapis.com/drive/v3/files/"
|
||||||
this.resolveQueue = []
|
this.resolveQueue = []
|
||||||
this.queueActive = false
|
this.queueActive = false
|
||||||
|
this.clientCallbackBind = this.clientCallback.bind(this)
|
||||||
}
|
}
|
||||||
browse(lockedCallback, errorCallback){
|
browse(lockedCallback, errorCallback){
|
||||||
return this.loadApi()
|
return this.loadApi()
|
||||||
@ -123,9 +124,12 @@ class Gpicker{
|
|||||||
if(window.gapi && gapi.client && gapi.client.drive){
|
if(window.gapi && gapi.client && gapi.client.drive){
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
return loader.loadScript("https://apis.google.com/js/api.js")
|
var promises = [
|
||||||
.then(() => new Promise((resolve, reject) =>
|
loader.loadScript("https://apis.google.com/js/api.js"),
|
||||||
gapi.load("auth2:picker:client", {
|
loader.loadScript("https://accounts.google.com/gsi/client")
|
||||||
|
]
|
||||||
|
return Promise.all(promises).then(() => new Promise((resolve, reject) =>
|
||||||
|
gapi.load("picker:client", {
|
||||||
callback: resolve,
|
callback: resolve,
|
||||||
onerror: reject
|
onerror: reject
|
||||||
})
|
})
|
||||||
@ -134,58 +138,53 @@ class Gpicker{
|
|||||||
gapi.client.load("drive", "v3").then(resolve, reject)
|
gapi.client.load("drive", "v3").then(resolve, reject)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
getAuth(errorCallback=()=>{}){
|
getClient(errorCallback=()=>{}, force){
|
||||||
if(!this.auth){
|
var obj = {
|
||||||
return new Promise((resolve, reject) => {
|
client_id: this.oauthClientId,
|
||||||
gapi.auth2.init({
|
scope: this.scope,
|
||||||
clientId: this.oauthClientId,
|
callback: this.clientCallbackBind
|
||||||
fetch_basic_profile: false,
|
|
||||||
scope: this.scope
|
|
||||||
}).then(() => {
|
|
||||||
this.auth = gapi.auth2.getAuthInstance()
|
|
||||||
resolve(this.auth)
|
|
||||||
}, e => {
|
|
||||||
if(e.details){
|
|
||||||
var errorStr = strings.gpicker.authError.replace("%s", e.details)
|
|
||||||
if(/cookie/i.test(e.details)){
|
|
||||||
errorStr += "\n\n" + strings.gpicker.cookieError
|
|
||||||
}
|
}
|
||||||
errorCallback(errorStr)
|
if(force){
|
||||||
|
if(!this.clientForce){
|
||||||
|
obj.select_account = true
|
||||||
|
this.clientForce = google.accounts.oauth2.initTokenClient(obj)
|
||||||
}
|
}
|
||||||
reject(e)
|
return this.clientForce
|
||||||
})
|
|
||||||
})
|
|
||||||
}else{
|
}else{
|
||||||
return Promise.resolve(this.auth)
|
if(!this.client){
|
||||||
|
this.client = google.accounts.oauth2.initTokenClient(obj)
|
||||||
|
}
|
||||||
|
return this.client
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clientCallback(tokenResponse){
|
||||||
|
this.tokenResponse = tokenResponse
|
||||||
|
this.oauthToken = tokenResponse.access_token
|
||||||
|
if(this.oauthToken && this.tokenResolve){
|
||||||
|
this.tokenResolve()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getToken(lockedCallback=()=>{}, errorCallback=()=>{}, force){
|
getToken(lockedCallback=()=>{}, errorCallback=()=>{}, force){
|
||||||
if(this.oauthToken && !force){
|
if(this.oauthToken && !force){
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
return this.getAuth(errorCallback).then(auth => {
|
var client = this.getClient(errorCallback, force)
|
||||||
var user = force || auth.currentUser.get()
|
var promise = new Promise(resolve => {
|
||||||
if(force || !this.checkScope(user)){
|
this.tokenResolve = resolve
|
||||||
|
})
|
||||||
lockedCallback(false)
|
lockedCallback(false)
|
||||||
return auth.signIn(force ? {
|
client.requestAccessToken()
|
||||||
prompt: "select_account"
|
return promise.then(() => {
|
||||||
} : undefined).then(user => {
|
this.tokenResolve = null
|
||||||
if(this.checkScope(user)){
|
if(this.checkScope()){
|
||||||
lockedCallback(true)
|
lockedCallback(true)
|
||||||
}else{
|
}else{
|
||||||
return Promise.reject("cancel")
|
return Promise.reject("cancel")
|
||||||
}
|
}
|
||||||
}, () => Promise.reject("cancel"))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
checkScope(user){
|
checkScope(){
|
||||||
if(user.hasGrantedScopes(this.scope)){
|
return google.accounts.oauth2.hasGrantedAnyScope(this.tokenResponse, this.scope)
|
||||||
this.oauthToken = user.getAuthResponse(true).access_token
|
|
||||||
return this.oauthToken
|
|
||||||
}else{
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
switchAccounts(lockedCallback, errorCallback){
|
switchAccounts(lockedCallback, errorCallback){
|
||||||
return this.loadApi().then(() => this.getToken(lockedCallback, errorCallback, true))
|
return this.loadApi().then(() => this.getToken(lockedCallback, errorCallback, true))
|
||||||
|
@ -23,10 +23,7 @@ You can use the Google Drive integration to let Taiko Web make your Taiko chart
|
|||||||
|
|
||||||
Applications that integrate with a Google account must declare their intent by requesting permissions. These permissions to your account must be granted in order for Taiko Web to integrate with Google accounts. Below is a list of these permissions and why they are required. At no time will Taiko Web request or have access to your Google account password.
|
Applications that integrate with a Google account must declare their intent by requesting permissions. These permissions to your account must be granted in order for Taiko Web to integrate with Google accounts. Below is a list of these permissions and why they are required. At no time will Taiko Web request or have access to your Google account password.
|
||||||
|
|
||||||
3.1 "Associate you with your personal info on Google" Permission
|
3.1 "See and download all your Google Drive files" Permission
|
||||||
Required for Google Sign-In to provide Taiko Web with a non-identifiable user authentication token. No other information provided by this permission is used.
|
|
||||||
|
|
||||||
3.2 "See and download all your Google Drive files" Permission
|
|
||||||
When selecting a folder with the Google Drive file picker, Taiko Web instructs your Browser to recursively download all the files of that folder directly into your computer's memory. Limitation of Google Drive's permission model requires us to request access to all your Google Drive files, however, Taiko Web will only access the selected folder and its children, and only when requested. File parsing is handled locally; none of your Google Drive files is ever sent to our servers or third parties.
|
When selecting a folder with the Google Drive file picker, Taiko Web instructs your Browser to recursively download all the files of that folder directly into your computer's memory. Limitation of Google Drive's permission model requires us to request access to all your Google Drive files, however, Taiko Web will only access the selected folder and its children, and only when requested. File parsing is handled locally; none of your Google Drive files is ever sent to our servers or third parties.
|
||||||
{% endif %}{% if config.email %}
|
{% endif %}{% if config.email %}
|
||||||
{% if integration %}4{% else %}3{% endif %}. Contact Info
|
{% if integration %}4{% else %}3{% endif %}. Contact Info
|
||||||
|
Loading…
Reference in New Issue
Block a user