VueGapi 在请求多个范围时什么都不做
VueGapi do nothing when requesting with multiple scopes
这是我的 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
。我哪里做错了?
scope
should be a space-delimited string.
尝试
...
scope: SCOPES.join(' ')
...
这是我的 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
。我哪里做错了?
scope
should be a space-delimited string.
尝试
...
scope: SCOPES.join(' ')
...