首页 > 解决方案 > 通过指定 URI、HTTP 方法、标头、内容类型和请求正文来构造您的 HTTP 请求

问题描述

I am trying to authorize gapi for the first time but am very unfamiliar with alot of the information being requested

ALl the sample videos, quick starts and samples

<!DOCTYPE html>
<html>

<head>
    <title>Drive API Quickstart</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" 

我正在尝试运行示例代码来授权 gapi,但无法突破快速入门中描述的元素障碍。添加本地主机后,除了我看到根目录中所有文件夹的超链接菜单外,什么都没有发生~

    <p>Drive API Quickstart</p>

    <!--Add buttons to initiate auth sequence and sign out-->
    <button id="authorize_button" style="display:block;">Authorize</button>
    <button id="signout_button" style="display: block;">Sign Out</button>

    <pre id="content" style="white-space: pre-wrap;"></pre>

    <script type="text/javascript">
        // Client ID and API key from the Developer Console
        var CLIENT_ID = 'CLIENT ID Obtained from GCP authorizaion after enbling APIS';
        var API_KEY = 'API Key obtained';

        // Array of API discovery doc URLs for APIs used by the quickstart
        var DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"];

        // Authorization scopes required by the API; multiple scopes can be
        // included, separated by spaces.
        var SCOPES = 

' https://www.googleapis.com/auth/drive.metadata.readonly ';

        var authorizeButton = document.getElementById('authorize_button');
        var signoutButton = document.getElementById('signout_button');

        /**
         *  On load, called to load the auth2 library and API client library.
         */
        function handleClientLoad() {
            gapi.load('client:auth2', initClient);
        }

        /**
         *  Initializes the API client library and sets up sign-in state
         *  listeners.
         ...

    <script async defer src="https://apis.google.com/js/api.js" onload="this.onload=function(){};handleClientLoad()"
        onreadystatechange="if (this.readyState === 'complete') this.onload()">
        </script>
</body>

</html>

when i get to 3 a. (Load the URL http://localhost:8000 into your browser.) nothing happens although I can see in cmd http 200

标签: google-api-js-client

解决方案


推荐阅读