這是我的 Vue3 main.js
app.use(VueGapi, {
apiKey: 'MyApiKey',
clientId: 'myClientId.apps.googleusercontent.com',
discoveryDocs: ['https://classroom.googleapis.com/$discovery/rest?version=v1'],
scope: "https://www.googleapis.com/auth/classroom.profile",
})
app.mount('#app')
但我需要提供很多范圍,所以我做了
const SCOPES = ['https://www.googleapis.com/auth/classroom.courses.readonly',
'https://www.googleapis.com/auth/classroom.profile.emails',
'https://www.googleapis.com/auth/classroom.profile.photos',
'https://www.googleapis.com/auth/classroom.rosters',
'https://www.googleapis.com/auth/classroom.rosters.readonly'];
并分配SCOPES給scope
app.use(VueGapi, {
apiKey: 'MyApiKey',
clientId: 'myClientId.apps.googleusercontent.com',
discoveryDocs: ['https://classroom.googleapis.com/$discovery/rest?version=v1'],
scope: SCOPES,
})
app.mount('#app')
從我的 vue 組件,呼叫
this.$gapi.login().then(({ currentUser, gapi, hasGrantedScopes }) => {
console.log({ currentUser, gapi, hasGrantedScopes })
})
當我按下登錄按鈕時,僅當我設定scope為單一范圍時才有效scope: "https://www.googleapis.com/auth/classroom.profile",但當我分配SCOPES給scope. 我哪里做錯了?
uj5u.com熱心網友回復:
scope 應該是一個空格分隔的字串。
嘗試
...
scope: SCOPES.join(' ')
...
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/346180.html
