{"id":1779,"date":"2022-10-11T23:40:14","date_gmt":"2022-10-11T15:40:14","guid":{"rendered":"https:\/\/swf.com.tw\/?p=1779"},"modified":"2022-10-11T23:40:16","modified_gmt":"2022-10-11T15:40:16","slug":"%e9%80%8f%e9%81%8epython-flask%e7%b6%b2%e7%ab%99%e7%a8%8b%e5%bc%8f%e4%b8%8a%e5%82%b3%e5%bd%b1%e5%83%8f%e6%aa%94%e5%88%b0google-drive%e9%9b%b2%e7%ab%af%e7%a1%ac%e7%a2%9f%ef%bc%88%e4%ba%8c%ef%bc%89","status":"publish","type":"post","link":"https:\/\/swf.com.tw\/?p=1779","title":{"rendered":"\u900f\u904ePython Flask\u7db2\u7ad9\u7a0b\u5f0f\u4e0a\u50b3\u5f71\u50cf\u6a94\u5230Google Drive\u96f2\u7aef\u786c\u789f\uff08\u4e8c\uff09"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4e0a\u4e00\u7bc7\u8cbc\u6587\u5c11\u4e86\u300c<strong>\u555f\u7528Google Drive API<\/strong>\u300d\u9019\u500b\u6b65\u9a5f\uff0c\u82e5\u60f3\u8981\u8b93\u5c08\u6848\u88e1\u7684\u670d\u52d9\u5e33\u6236\u57f7\u884cGoogle Drive\u96f2\u7aef\u786c\u789f\u7684API\uff0c\u5fc5\u9808\u555f\u7528\u5b83\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u555f\u7528Google Drive API<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u56de\u5230<a href=\"https:\/\/console.cloud.google.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Google Cloud\u96f2\u7aef\u5e73\u53f0\u7684\u63a7\u5236\u53f0<\/a>\uff0c\u6309\u4e00\u4e0b\u9801\u9762\u5de6\u4e0a\u89d2\u3001Google Cloud\u6a19\u8a8c\u65c1\u908a\u7684\u4e3b\u9078\u55ae\uff0c\u9ede\u64ca\u300c<strong>API\u548c\u670d\u52d9<\/strong>\u300d\u2192\u300c<strong>\u5df2\u555f\u7528\u7684API\u548c\u670d\u52d9<\/strong>\u300d\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/enable_google_drive_1.png\" alt=\"\u5df2\u555f\u7528\u7684API\u548c\u670d\u52d9\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u9ede\u64ca\u756b\u9762\u4e0a\u65b9\u7684\u300c<strong>\u555f\u7528API\u548c\u670d\u52d9<\/strong>\u300d\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/enable_google_drive_2.png\" alt=\"\u555f\u7528API\u548c\u670d\u52d9\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u641c\u5c0b\u6b04\u4f4d\u8f38\u5165\u201cgoogle drive\u201d\u95dc\u9375\u5b57\uff0c\u627e\u51faGoogle\u96f2\u7aef\u786c\u789f\u7684API\u670d\u52d9\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/enable_google_drive_3.png\" alt=\"\u8f38\u5165\u201cgoogle drive\u201d\u95dc\u9375\u5b57\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u9ede\u64ca\u627e\u5230\u7684<strong>Google Drive API<\/strong>\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/enable_google_drive_4.png\" alt=\"\u9ede\u64caGoogle Drive API\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u9032\u5165Google Drive API\u670d\u52d9\u756b\u9762\u5f8c\uff0c\u9ede\u64ca\u300c<strong>\u555f\u7528<\/strong>\u300d\u3002\u904e\u4e00\u6703\u5152\uff0c\u7b49\u5b83\u5207\u63db\u9801\u9762\u5c31\u555f\u7528\u6210\u529f\uff0c\u9019\u500b\u7db2\u9801\u4e5f\u5c31\u53ef\u4ee5\u95dc\u9589\u4e86\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/enable_google_drive_5.png\" alt=\"\u555f\u7528Google Drive API\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u8a2d\u5b9aGoogle Drive\u96f2\u7aef\u786c\u789f\u7684\u5171\u7528\u8cc7\u6599\u593e<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u9032\u5165<a href=\"https:\/\/drive.google.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Google\u96f2\u7aef\u786c\u789f<\/a>\uff0c\u65b0\u589e\u4e00\u500b\u5373\u5c07\u7528\u4f86\u5132\u5b58Python\u7a0b\u5f0f\u4e0a\u50b3\u5f71\u50cf\u7684\u8cc7\u6599\u593e\uff0c\u7b46\u8005\u5c07\u5b83\u547d\u540d\u70baESP32CAM\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/google_drive_folder.png\" alt=\"\u96f2\u7aef\u786c\u789f\u7684\u8cc7\u6599\u593e\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u8cc7\u6599\u593e\u4e0a\u6309\u53f3\u9375\uff0c\u9078\u64c7\u300c<strong>\u5171\u7528<\/strong>\u300d\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/drive_folder_share_1.png\" alt=\"\u5171\u7528\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u300c\u65b0\u589e\u4f7f\u7528\u8005\u548c\u7fa4\u7d44\u300d\u6b04\u4f4d\u8cbc\u5165\u4e4b\u524d\u5728Google\u96f2\u7aef\u5e73\u53f0\u65b0\u589e<strong>\u670d\u52d9\u5e33\u6236<\/strong>\u7684e-mail\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/drive_folder_share_2.png\" alt=\"\u5171\u7528ESP32CAM\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u53d6\u6d88\u300c\u901a\u77e5\u9080\u8acb\u5c0d\u8c61\u300d\uff0c\u78ba\u8a8d\u6b04\u4f4d\u53f3\u908a\u7684<strong>\u5b58\u53d6\u6b0a<\/strong>\u8a2d\u5b9a\u6210\u300c<strong>\u7de8\u8f2f\u8005<\/strong>\u300d\uff0c\u9019\u500b\u5e33\u6236\u624d\u80fd\u4e0a\u50b3\u6a94\u6848\u5230\u6b64\u8cc7\u6599\u593e\u3002\u6309\u4e0b\u300c<strong>\u5171\u7528<\/strong>\u300d\u5b8c\u6210\u8a2d\u5b9a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/drive_folder_share_3.png\" alt=\"\u5171\u7528ESP32CAM\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u96f2\u7aef\u786c\u789f\u7684\u300c\u8cc7\u6599\u593e\u540d\u7a31\u300d\u662f\u7d66\u4eba\u985e\u770b\u7684\uff0c\u540d\u7a31\u53ef\u4ee5\u91cd\u8907\uff0c\u6bcf\u500b\u8cc7\u6599\u593e\u548c\u6587\u4ef6\u90fd\u6709\u500b\u552f\u4e00\u7684ID\u8b58\u5225\u78bc\uff1b\u7a0b\u5f0f\u900f\u904eID\u8b58\u5225\u78bc\u5b58\u53d6\u96f2\u7aef\u786c\u789f\u8cc7\u6599\u593e\u3002\u53d6\u5f97\u8cc7\u6599\u593eID\u6700\u7c21\u55ae\u7684\u65b9\u6cd5\uff1a\u6253\u958b\u8a72\u8cc7\u6599\u593e\uff0c\u7db2\u5740\u201cfolders\/\u201d\u5f8c\u9762\u7684\u4e00\u9023\u4e32\u6587\u5b57\u5c31\u662f\u5b83\u7684ID\uff0c\u8acb\u5c07\u5b83\u8907\u88fd\u4e0b\u4f86\u5099\u7528\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/drive_folder_id.png\" alt=\"\u8cc7\u6599\u593e\u7684ID\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e0a\u50b3\u5f71\u50cf\u6a94\u5230Google Drive\u96f2\u7aef\u786c\u789f\u7684Python\u7a0b\u5f0f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b46\u8005\u5728\u96fb\u8166\u7684D\u78c1\u789f\u6839\u76ee\u9304\u5e95\u4e0b\uff0c\u65b0\u589e\u4e00\u500b\u201cgoogle_drive\u201d\u8cc7\u6599\u593e\uff0c\u5728\u5176\u4e2d\u8a2d\u5b9aPython\u865b\u64ec\u74b0\u5883\u3002\u6b64\u865b\u64ec\u74b0\u5883\u7684src\u8cc7\u6599\u593e\u5305\u542b\u4e09\u500b\u6a94\u6848\uff0capp.py\u662f\u4e0a\u50b3\u5f71\u50cf\u5230Google\u96f2\u7aef\u786c\u789f\u7684Python\u7a0b\u5f0f\u6a94\u3002\u8ddf\u66f8\u672c\u7684\u7bc4\u4f8b\u4e00\u6a23\uff0c\u7b46\u8005\u628a\u670d\u52d9\u5e33\u6236\u91d1\u9470\u7684.json\u6a94\u91cd\u65b0\u547d\u540d\u70bagoogle_auth.json\uff0c\u5b58\u5165src\u8cc7\u6599\u593e\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/upload_example_env.png\" alt=\"Python\u865b\u64ec\u74b0\u5883 \"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u9019\u500bPython\u7a0b\u5f0f\u7684\u529f\u80fd\u5f88\u55ae\u7d14\uff1a\u628a\u76f8\u540c\u8def\u5f91\u88e1\u7684photo.jpg\u4e0a\u50b3\u5230Google\u96f2\u7aef\u786c\u789f\u7684\u201cESP32CAM\u201d\u8cc7\u6599\u593e\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u5728\u6b64<strong>\u865b\u64ec\u74b0\u5883<\/strong>\u4e2d\u57f7\u884cpip\u547d\u4ee4\u5b89\u88ddGoogle API\u7684\u7a0b\u5f0f\u5eab\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pip install google-api-python-client --upgrade<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f7f\u7528Google API Python Client\u9a57\u8b49\u670d\u52d9\u5e33\u6236\u8207\u4e0a\u50b3\u6a94\u6848<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c7\u7ae0\u7684\u5b58\u53d6Google\u8a66\u7b97\u8868\u7684\u7bc4\u4f8b\u7a0b\u5f0f\uff0c\u63a1\u7528<a href=\"https:\/\/pypi.org\/project\/oauth2client\/\" target=\"_blank\" rel=\"noreferrer noopener\">oauth2client\uff08OAuth\u9a57\u8b49\u524d\u7aef\uff09<\/a>\u6a21\u7d44\u8655\u7406\u91d1\u9470\u6191\u8b49\u6a94\u6848\uff0c\u672c\u6587\u6539\u7528Google\u81ea\u5bb6\u7684<a href=\"https:\/\/github.com\/googleapis\/google-api-python-client\/blob\/main\/docs\/\" target=\"_blank\" rel=\"noreferrer noopener\">API Python\u7528\u6236\u7aef\u7a0b\u5f0f\u5eab\uff08Google API Python Client\uff09<\/a>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u5728\u7a0b\u5f0f\u958b\u982d\u5f15\u7528\u4e09\u500bGoogle API\u6a21\u7d44\uff0c\u5b83\u5011\u5206\u5225\u7528\u65bc\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u9a57\u8b49<strong>\u670d\u52d9\u5e33\u6236\uff08service_account\uff09<\/strong><\/li><li>\u5efa\u7acb\u7528\u65bc\u64cd\u4f5c\u96f2\u7aef\u670d\u52d9\u7684<strong>\u670d\u52d9\uff08service\uff09<\/strong>\u7269\u4ef6<\/li><li>\u4e0a\u50b3\u5a92\u9ad4\u6a94\u6848\uff08MediaFileUpload\uff09<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b83\u5011\u4e5f\u6b63\u597d\u4ee3\u8868\u4e0a\u50b3\u6a94\u6848\u5230Google\u96f2\u7aef\u786c\u789f\u7684\u4e09\u5927\u8655\u7406\u6d41\u7a0b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from google.oauth2 import service_account\nfrom googleapiclient.discovery import build\nfrom googleapiclient.http import  MediaFileUpload<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u9a57\u8b49\u670d\u52d9\u5e33\u6236\u3001\u5efa\u7acb<strong>\u6191\u8b49\uff08credential\uff09\u7269\u4ef6<\/strong>\u7684\u7a0b\u5f0f\u7247\u6bb5\u5982\u4e0b\uff0c\u5176\u4e2d\u7684<strong>\u670d\u52d9\u7bc4\u7587\uff08scope\uff09<\/strong>\u5b57\u4e32\u662f\u7db2\u5740\u5f62\u5f0f\uff0cGoogle Drive API\u7b2c\u4e09\u7248\u7684\u6240\u6709\u670d\u52d9\u7bc4\u7587\u540d\u7a31\uff0c\u8acb\u53c3\u95b1<a href=\"https:\/\/developers.google.com\/identity\/protocols\/oauth2\/scopes#drive\" target=\"_blank\" rel=\"noreferrer noopener\">\u9019\u500bDrive API, v3\u5217\u8868<\/a>\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/credential_obj.png\" alt=\"\u5efa\u7acb\u6191\u8b49\uff08credential\uff09\u7269\u4ef6\u7684\u7a0b\u5f0f\u7247\u6bb5\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6709\u4e86\u6191\u8b49\u7269\u4ef6\uff0c\u4fbf\u53ef\u900f\u904e<strong>build\u51fd\u5f0f<\/strong>\u7522\u751f<strong>\u670d\u52d9\u7269\u4ef6<\/strong>\uff0c\u5b83\u63a5\u65363\u500b\u53c3\u6578\uff0c\u9019\u500b\u7a0b\u5f0f\u63a1\u7528Google Drive, v3\u7248\uff0c\u6240\u4ee5\u524d\u5169\u500b\u53c3\u6578\u503c\u5206\u5225\u662f\u201cdrive\u201d\u548c\u201cv3\u201d\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/service_obj.png\" alt=\"\u900f\u904ebuild\u51fd\u5f0f\u7522\u751f\u670d\u52d9\u7269\u4ef6\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u50b3\u6a94\u6848\u4e4b\u524d\uff0c\u5148\u5b9a\u7fa9\u4e00\u4e9b\u8b8a\u6578\uff0c\u5132\u5b58\u8cc7\u6599\u593e\u548c\u6a94\u6848\u7684\u76f8\u95dc\u8cc7\u6599\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/file_var.png\" alt=\"\u5b9a\u7fa9\u8b8a\u6578\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u50b3\u6a94\u6848\u8981\u5305\u88dd\u6210<strong>MediaFileUpload\u7269\u4ef6<\/strong>\uff0c\u518d\u4ea4\u7d66<strong>\u670d\u52d9\uff08service\uff09<\/strong>\u7269\u4ef6\u7684create\uff08\u4ee3\u8868\u300c\u5efa\u7acb\u6a94\u6848\u300d\uff09\u65b9\u6cd5\uff0c\u5728Google\u96f2\u7aef\u786c\u789f\u5efa\u7acb\u6a94\u6848\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/python\/google_drive\/upload_file.png\" alt=\"\u4e0a\u50b3\u6a94\u6848\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u57f7\u884c\u4e0a\u9762\u7684\u7a0b\u5f0f\u7247\u6bb5\uff0cphoto.jpg\u6a94\u65cb\u5373\u88ab\u4e0a\u50b3\u5230\u96f2\u7aef\u786c\u789f\u7684ESP32CAM\u8cc7\u6599\u593e\uff0c\u4e0a\u50b3\u5b8c\u7562\u5f8c\uff0cfile_id\u5c07\u63a5\u6536\u5230\u985e\u4f3c\u5e95\u4e0b\u5167\u5bb9\u7684\u5b57\u5178\u578b\u614b\u8cc7\u6599\uff0c\u5176\u4e2d\u7684id\u662fGoogle\u96f2\u7aef\u786c\u789f\u6307\u6d3e\u7d66\u9019\u500b\u4e0a\u50b3\u6a94\u7684ID\u8b58\u5225\u540d\u7a31\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{ 'kind': 'drive#file', 'id': '1bsKRc3\u2026\u7565\u2026', 'name': 'photo.jpg',  'mimeType': 'image\/jpeg'}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b8c\u6574\u7684\u4e0a\u50b3\u6a94\u6848\u7bc4\u4f8bapp.py\u6a94\u7684\u7a0b\u5f0f\u78bc\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from google.oauth2 import service_account\nfrom googleapiclient.discovery import build\nfrom googleapiclient.http import MediaFileUpload\n\nUPLOAD_FOLDER = '\u8acb\u8f38\u5165\u4f60\u7684\u4e0a\u50b3\u6a94\u8cc7\u6599\u593e\u7684ID'\nSCOPES = ['https:\/\/www.googleapis.com\/auth\/drive']\nSERVICE_ACCOUNT_FILE = 'google_auth.json'  # \u91d1\u9470\u6a94\u6848\n\n# \u5efa\u7acb\u6191\u8b49\u7269\u4ef6\ncreds = service_account.Credentials.from_service_account_file(\n    SERVICE_ACCOUNT_FILE, scopes=SCOPES)\n\nservice = build('drive', 'v3', credentials=creds)\n\nfilename = \"photo.jpg\"    # \u4e0a\u50b3\u6a94\u7684\u540d\u5b57\nmedia = MediaFileUpload(filename)\nfile = {'name': filename, 'parents': [UPLOAD_FOLDER]}\n\nprint(\"\u6b63\u5728\u4e0a\u50b3\u6a94\u6848...\")\nfile_id = service.files().create(body=file, media_body=media).execute()\nprint('\u96f2\u7aef\u6a94\u6848ID\uff1a' + str(file_id['id']))\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c7\u7ae0\u7684\u5b58\u53d6Google\u8a66\u7b97\u8868\u7684\u7bc4\u4f8b\u7a0b\u5f0f\uff0c\u63a1\u7528oauth2client\uff08OAuth\u9a57\u8b49\u524d\u7aef\uff09\u6a21\u7d44\u8655\u7406\u91d1\u9470\u6191\u8b49\u6a94\u6848\uff0c\u672c\u6587\u6539\u7528Google\u81ea\u5bb6\u7684API Python\u7528\u6236\u7aef\u7a0b\u5f0f\u5eab\uff08Google API Python Client\uff09\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/images\/books\/python\/google_drive\/upload_example_env.png\" width=\"520\" height=\"414\" alt=\"Python\u865b\u64ec\u74b0\u5883 \"\/> <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[3],"tags":[49],"class_list":["post-1779","post","type-post","status-publish","format-standard","hentry","category-3","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u900f\u904ePython Flask\u7db2\u7ad9\u7a0b\u5f0f\u4e0a\u50b3\u5f71\u50cf\u6a94\u5230Google Drive\u96f2\u7aef\u786c\u789f\uff08\u4e8c\uff09 - \u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8<\/title>\n<meta name=\"description\" content=\"\u7b2c7\u7ae0\u7684\u5b58\u53d6Google\u8a66\u7b97\u8868\u7684\u7bc4\u4f8b\u7a0b\u5f0f\uff0c\u63a1\u7528oauth2client\uff08OAuth\u9a57\u8b49\u524d\u7aef\uff09\u6a21\u7d44\u8655\u7406\u91d1\u9470\u6191\u8b49\u6a94\u6848\uff0c\u672c\u6587\u6539\u7528Google\u81ea\u5bb6\u7684API Python\u7528\u6236\u7aef\u7a0b\u5f0f\u5eab\uff08Google API Python Client\uff09\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swf.com.tw\/?p=1779\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005:\" \/>\n\t<meta name=\"twitter:data1\" content=\"cubie\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9810\u4f30\u95b1\u8b80\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\u9418\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1779#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1779\"},\"author\":{\"name\":\"cubie\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#\\\/schema\\\/person\\\/24480fda9184aa137df8f05d79bc2f57\"},\"headline\":\"\u900f\u904ePython Flask\u7db2\u7ad9\u7a0b\u5f0f\u4e0a\u50b3\u5f71\u50cf\u6a94\u5230Google Drive\u96f2\u7aef\u786c\u789f\uff08\u4e8c\uff09\",\"datePublished\":\"2022-10-11T15:40:14+00:00\",\"dateModified\":\"2022-10-11T15:40:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1779\"},\"wordCount\":120,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#organization\"},\"keywords\":[\"Python\"],\"articleSection\":[\"\u6559\u5b78\u6587\u4ef6\"],\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/swf.com.tw\\\/?p=1779#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1779\",\"url\":\"https:\\\/\\\/swf.com.tw\\\/?p=1779\",\"name\":\"\u900f\u904ePython Flask\u7db2\u7ad9\u7a0b\u5f0f\u4e0a\u50b3\u5f71\u50cf\u6a94\u5230Google Drive\u96f2\u7aef\u786c\u789f\uff08\u4e8c\uff09 - \u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#website\"},\"datePublished\":\"2022-10-11T15:40:14+00:00\",\"dateModified\":\"2022-10-11T15:40:16+00:00\",\"description\":\"\u7b2c7\u7ae0\u7684\u5b58\u53d6Google\u8a66\u7b97\u8868\u7684\u7bc4\u4f8b\u7a0b\u5f0f\uff0c\u63a1\u7528oauth2client\uff08OAuth\u9a57\u8b49\u524d\u7aef\uff09\u6a21\u7d44\u8655\u7406\u91d1\u9470\u6191\u8b49\u6a94\u6848\uff0c\u672c\u6587\u6539\u7528Google\u81ea\u5bb6\u7684API Python\u7528\u6236\u7aef\u7a0b\u5f0f\u5eab\uff08Google API Python Client\uff09\u3002\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1779#breadcrumb\"},\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swf.com.tw\\\/?p=1779\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1779#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swf.com.tw\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u900f\u904ePython Flask\u7db2\u7ad9\u7a0b\u5f0f\u4e0a\u50b3\u5f71\u50cf\u6a94\u5230Google Drive\u96f2\u7aef\u786c\u789f\uff08\u4e8c\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#website\",\"url\":\"https:\\\/\\\/swf.com.tw\\\/\",\"name\":\"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8\",\"description\":\"Arduino+Python+JavaScript+\u7a0b\u5f0f\u8a2d\u8a08+\u786c\u9ad4DIY\",\"publisher\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swf.com.tw\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-TW\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#organization\",\"name\":\"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8\",\"url\":\"https:\\\/\\\/swf.com.tw\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swf.com.tw\\\/wp-content\\\/uploads\\\/2019\\\/10\\\/logo_bat.png\",\"contentUrl\":\"https:\\\/\\\/swf.com.tw\\\/wp-content\\\/uploads\\\/2019\\\/10\\\/logo_bat.png\",\"width\":71,\"height\":65,\"caption\":\"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8\"},\"image\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#\\\/schema\\\/person\\\/24480fda9184aa137df8f05d79bc2f57\",\"name\":\"cubie\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g\",\"caption\":\"cubie\"},\"sameAs\":[\"https:\\\/\\\/swf.com.tw\"],\"url\":\"https:\\\/\\\/swf.com.tw\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u900f\u904ePython Flask\u7db2\u7ad9\u7a0b\u5f0f\u4e0a\u50b3\u5f71\u50cf\u6a94\u5230Google Drive\u96f2\u7aef\u786c\u789f\uff08\u4e8c\uff09 - \u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8","description":"\u7b2c7\u7ae0\u7684\u5b58\u53d6Google\u8a66\u7b97\u8868\u7684\u7bc4\u4f8b\u7a0b\u5f0f\uff0c\u63a1\u7528oauth2client\uff08OAuth\u9a57\u8b49\u524d\u7aef\uff09\u6a21\u7d44\u8655\u7406\u91d1\u9470\u6191\u8b49\u6a94\u6848\uff0c\u672c\u6587\u6539\u7528Google\u81ea\u5bb6\u7684API Python\u7528\u6236\u7aef\u7a0b\u5f0f\u5eab\uff08Google API Python Client\uff09\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swf.com.tw\/?p=1779","twitter_misc":{"\u4f5c\u8005:":"cubie","\u9810\u4f30\u95b1\u8b80\u6642\u9593":"4 \u5206\u9418"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swf.com.tw\/?p=1779#article","isPartOf":{"@id":"https:\/\/swf.com.tw\/?p=1779"},"author":{"name":"cubie","@id":"https:\/\/swf.com.tw\/#\/schema\/person\/24480fda9184aa137df8f05d79bc2f57"},"headline":"\u900f\u904ePython Flask\u7db2\u7ad9\u7a0b\u5f0f\u4e0a\u50b3\u5f71\u50cf\u6a94\u5230Google Drive\u96f2\u7aef\u786c\u789f\uff08\u4e8c\uff09","datePublished":"2022-10-11T15:40:14+00:00","dateModified":"2022-10-11T15:40:16+00:00","mainEntityOfPage":{"@id":"https:\/\/swf.com.tw\/?p=1779"},"wordCount":120,"commentCount":0,"publisher":{"@id":"https:\/\/swf.com.tw\/#organization"},"keywords":["Python"],"articleSection":["\u6559\u5b78\u6587\u4ef6"],"inLanguage":"zh-TW","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/swf.com.tw\/?p=1779#respond"]}]},{"@type":"WebPage","@id":"https:\/\/swf.com.tw\/?p=1779","url":"https:\/\/swf.com.tw\/?p=1779","name":"\u900f\u904ePython Flask\u7db2\u7ad9\u7a0b\u5f0f\u4e0a\u50b3\u5f71\u50cf\u6a94\u5230Google Drive\u96f2\u7aef\u786c\u789f\uff08\u4e8c\uff09 - \u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8","isPartOf":{"@id":"https:\/\/swf.com.tw\/#website"},"datePublished":"2022-10-11T15:40:14+00:00","dateModified":"2022-10-11T15:40:16+00:00","description":"\u7b2c7\u7ae0\u7684\u5b58\u53d6Google\u8a66\u7b97\u8868\u7684\u7bc4\u4f8b\u7a0b\u5f0f\uff0c\u63a1\u7528oauth2client\uff08OAuth\u9a57\u8b49\u524d\u7aef\uff09\u6a21\u7d44\u8655\u7406\u91d1\u9470\u6191\u8b49\u6a94\u6848\uff0c\u672c\u6587\u6539\u7528Google\u81ea\u5bb6\u7684API Python\u7528\u6236\u7aef\u7a0b\u5f0f\u5eab\uff08Google API Python Client\uff09\u3002","breadcrumb":{"@id":"https:\/\/swf.com.tw\/?p=1779#breadcrumb"},"inLanguage":"zh-TW","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swf.com.tw\/?p=1779"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/swf.com.tw\/?p=1779#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swf.com.tw\/"},{"@type":"ListItem","position":2,"name":"\u900f\u904ePython Flask\u7db2\u7ad9\u7a0b\u5f0f\u4e0a\u50b3\u5f71\u50cf\u6a94\u5230Google Drive\u96f2\u7aef\u786c\u789f\uff08\u4e8c\uff09"}]},{"@type":"WebSite","@id":"https:\/\/swf.com.tw\/#website","url":"https:\/\/swf.com.tw\/","name":"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8","description":"Arduino+Python+JavaScript+\u7a0b\u5f0f\u8a2d\u8a08+\u786c\u9ad4DIY","publisher":{"@id":"https:\/\/swf.com.tw\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swf.com.tw\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-TW"},{"@type":"Organization","@id":"https:\/\/swf.com.tw\/#organization","name":"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8","url":"https:\/\/swf.com.tw\/","logo":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/swf.com.tw\/#\/schema\/logo\/image\/","url":"https:\/\/swf.com.tw\/wp-content\/uploads\/2019\/10\/logo_bat.png","contentUrl":"https:\/\/swf.com.tw\/wp-content\/uploads\/2019\/10\/logo_bat.png","width":71,"height":65,"caption":"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8"},"image":{"@id":"https:\/\/swf.com.tw\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/swf.com.tw\/#\/schema\/person\/24480fda9184aa137df8f05d79bc2f57","name":"cubie","image":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/secure.gravatar.com\/avatar\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g","caption":"cubie"},"sameAs":["https:\/\/swf.com.tw"],"url":"https:\/\/swf.com.tw\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/swf.com.tw\/index.php?rest_route=\/wp\/v2\/posts\/1779","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swf.com.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swf.com.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swf.com.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swf.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1779"}],"version-history":[{"count":0,"href":"https:\/\/swf.com.tw\/index.php?rest_route=\/wp\/v2\/posts\/1779\/revisions"}],"wp:attachment":[{"href":"https:\/\/swf.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swf.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swf.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}