【发布时间】:2019-08-14 07:14:29
【问题描述】:
所以我是新手,我正在尝试做的是使用 Angular 作为前端来制作一个简单的按钮,单击该按钮时要求用户进行身份验证,就像使用 gmail 示例的任何登录一样,但我不断收到此错误,在这里是我的代码我想做的是使用谷歌提供的代码 https://developers.google.com/gmail/api/v1/reference/users/messages/list 并将其转换为打字稿
app.component.ts
export class AppComponent {
async authenticate() {
return await gapi.auth2.getAuthInstance().signIn({
scope: 'https://www.googleapis.com/auth/gmail.readonly',
});
}
app.component.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<script src="https://apis.google.com/js/api.js"></script>
<title>Document</title>
</head>
<body>
<div class="wrapper">
<button class="signup" (click)="authenticate()">authorize and load</button>
</div>
<router-outlet></router-outlet>
</body>
</html>
【问题讨论】:
-
您是否包含了 Google 平台 API 脚本?
标签: angular typescript google-api-js-client