Vue.js 为Youtube API请求实现Oauth到NuxtJS
我在oAuth令牌请求中遇到问题,无法请求Youtube API 目前我只有YoutubeAPI.vue组件Vue.js 为Youtube API请求实现Oauth到NuxtJS,vue.js,oauth,axios,youtube-api,nuxt.js,Vue.js,Oauth,Axios,Youtube Api,Nuxt.js,我在oAuth令牌请求中遇到问题,无法请求Youtube API 目前我只有YoutubeAPI.vue组件 <template> <div> <button @click="getAuthorizationCode">Get authorixation</button> </div> </template> <script> export default { method
<template>
<div>
<button @click="getAuthorizationCode">Get authorixation</button>
</div>
</template>
<script>
export default {
methods: {
getAuthorizationCode () {
this.$auth.getToken('social')
}
}
}
</script>
问题是我哪儿都找不到代币。我还从Nuxt文档中找到了这个部分
auth: {
strategies: {
social: {
_scheme: 'oauth2',
authorization_endpoint: 'https://accounts.google.com/o/oauth2/auth',
userinfo_endpoint: 'https://www.googleapis.com/oauth2/v3/userinfo',
scope: ['openid', 'profile', 'email'],
access_type: undefined,
access_token_endpoint: undefined,
response_type: 'token',
token_type: 'Bearer',
redirect_uri: undefined,
client_id: 'SET_ME',
token_key: 'access_token',
state: 'UNIQUE_AND_NON_GUESSABLE'
}
}
}
但我不明白该怎么办。
有想法的人,如何解决用例,在哪里
- 页面上会显示Youtube视频
- 用户点击LIKE按钮
- 组件使用oAuth授权用户并获取oAuth令牌
- Nuxt/Axios正在向Youtube API发出请求,以喜欢视频
auth: {
strategies: {
social: {
_scheme: 'oauth2',
authorization_endpoint: 'https://accounts.google.com/o/oauth2/auth',
userinfo_endpoint: 'https://www.googleapis.com/oauth2/v3/userinfo',
scope: ['openid', 'profile', 'email'],
access_type: undefined,
access_token_endpoint: undefined,
response_type: 'token',
token_type: 'Bearer',
redirect_uri: undefined,
client_id: 'SET_ME',
token_key: 'access_token',
state: 'UNIQUE_AND_NON_GUESSABLE'
}
}
}