mirror of
https://github.com/jiojciojsioe3/a3cjroijsiojiorj.git
synced 2024-11-15 07:21:50 +08:00
Gpicker API Changes
Hopefully that is what is being changed, I do not think there is a way to test this properly until the old API closes down Resources: - https://developers.googleblog.com/2022/03/gis-jsweb-authz-migration.html - https://developers.google.com/drive/api/v3/quickstart/js
This commit is contained in:
parent
ab3c421ab4
commit
27c8526c2a
@ -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){
|
||||||
|
@ -9,6 +9,7 @@ class Gpicker{
|
|||||||
this.scope = "https://www.googleapis.com/auth/drive.readonly"
|
this.scope = "https://www.googleapis.com/auth/drive.readonly"
|
||||||
this.folder = "application/vnd.google-apps.folder"
|
this.folder = "application/vnd.google-apps.folder"
|
||||||
this.filesUrl = "https://www.googleapis.com/drive/v3/files/"
|
this.filesUrl = "https://www.googleapis.com/drive/v3/files/"
|
||||||
|
this.discoveryDocs = ["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"]
|
||||||
this.resolveQueue = []
|
this.resolveQueue = []
|
||||||
this.queueActive = false
|
this.queueActive = false
|
||||||
}
|
}
|
||||||
@ -138,7 +139,9 @@ class Gpicker{
|
|||||||
if(!this.auth){
|
if(!this.auth){
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
gapi.auth2.init({
|
gapi.auth2.init({
|
||||||
|
apiKey: this.apiKey,
|
||||||
clientId: this.oauthClientId,
|
clientId: this.oauthClientId,
|
||||||
|
discoveryDocs: this.discoveryDocs,
|
||||||
fetch_basic_profile: false,
|
fetch_basic_profile: false,
|
||||||
scope: this.scope
|
scope: this.scope
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
@ -164,22 +167,30 @@ class Gpicker{
|
|||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
return this.getAuth(errorCallback).then(auth => {
|
return this.getAuth(errorCallback).then(auth => {
|
||||||
var user = force || auth.currentUser.get()
|
if(!force && auth.isSignedIn.get() && this.checkScope()){
|
||||||
if(force || !this.checkScope(user)){
|
return Promise.resolve()
|
||||||
|
}else{
|
||||||
lockedCallback(false)
|
lockedCallback(false)
|
||||||
return auth.signIn(force ? {
|
return new Promise((resolve, reject) =>
|
||||||
prompt: "select_account"
|
auth.signIn({
|
||||||
} : undefined).then(user => {
|
prompt: force ? "select_account" : "consent",
|
||||||
if(this.checkScope(user)){
|
scope: this.scope
|
||||||
|
}).then(resolve, reject)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
if(this.checkScope()){
|
||||||
lockedCallback(true)
|
lockedCallback(true)
|
||||||
}else{
|
}else{
|
||||||
return Promise.reject("cancel")
|
return Promise.reject("cancel")
|
||||||
}
|
}
|
||||||
}, () => Promise.reject("cancel"))
|
}, e => {
|
||||||
}
|
console.error(e)
|
||||||
|
Promise.reject("cancel")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
checkScope(user){
|
checkScope(){
|
||||||
|
var user = this.auth.currentUser.get()
|
||||||
if(user.hasGrantedScopes(this.scope)){
|
if(user.hasGrantedScopes(this.scope)){
|
||||||
this.oauthToken = user.getAuthResponse(true).access_token
|
this.oauthToken = user.getAuthResponse(true).access_token
|
||||||
return this.oauthToken
|
return this.oauthToken
|
||||||
|
Loading…
Reference in New Issue
Block a user