这个问题仍未解决!如果你知道,请回答
窃听器
我在这里提交了一个错误
http://code.google.com/p/google-api-python-client/issues/detail?id=131&thanks=131&ts=1335708962
在处理我的gdrive-cli项目时,我遇到了这个错误,试图使用"text/plain"mime-type上传UTF-8降价文件.我也试过"text/plain; charset = utf-8"并得到了相同的结果.
这是我得到的堆栈跟踪:
Traceback (most recent call last):
File "./gdrive-cli", line 155, in <module>
handle_args(args)
File "./gdrive-cli", line 92, in handle_args
handle_insert(args.insert)
File "./gdrive-cli", line 126, in handle_insert
filename)
File "/home/tom/Github/gdrive-cli/gdrive/gdrive.py", line 146, in insert_file
media_body=media_body).execute()
File "/usr/local/lib/python2.7/dist-packages/apiclient/http.py", line 393, in execute
headers=self.headers)
File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 401, in new_request
redirections, connection_type)
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1544, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line …Run Code Online (Sandbox Code Playgroud) 我正在用Python开发一个Google App Engine应用程序.我正在使用:
我以为我必须使用服务帐户,因为这样:
"如果您的App Engine应用程序需要调用API来访问应用程序项目拥有的数据,则可以使用服务帐户简化OAuth 2.0"
摘自https://developers.google.com/api-client-library/python/platforms/google_app_engine#ServiceAccounts
但我不确定我是否误解了某些东西.我的方案(GAE应用尝试在我自己的域中访问Google Apps)是服务帐户的候选人吗?
我已经尝试了几种方法来处理OAuth2:
在这两种情况下,我都会遇到同样的错误:
我完全迷失了.有线索吗?
提前谢谢了
python google-app-engine google-calendar-api oauth-2.0 google-api-python-client
我想从Google Analytics中检索数据.我在控制台中创建了一个服务帐户,我正在使用Google的Python(hello_analytics_api_v3.py)代码来访问数据.
我已将其复制client_secrets.json到我的文件夹中但收到此错误:
*SystemExit:
WARNING: Please configure OAuth 2.0
To make this sample run you will need to populate the client_secrets.json file
found at:*
Run Code Online (Sandbox Code Playgroud)
我该怎么办?我使用的是Python 2.7.
我在我的app.yaml配置文件中使用'login'选项来获取GAE应用程序.看起来像这样:
- url: /admin/.*
script: myapp.app
login: admin
- url: /.*
script: myapp.app
login: required
Run Code Online (Sandbox Code Playgroud)
更新(通过bossylobster的建议):我希望用户始终登录(未签名的用户无法做任何事情),我需要知道用户是谁.实际上,我需要OAuth2凭据才能与Google API进行通信(例如,我需要使用Google个人资料API获取一些用户信息,并使用Google Calendar API在用户的日历中写入).最后,我需要管理员用户执行某些操作(例如使用Google Provisioning API创建新域用户)
我正在使用google-api-client库,并且使用oauth2装饰器.然后,在我的RequestHandlers中,我有这个:
class MainHandler(webapp.RequestHandler):
@decorator.oauth_aware
def get(self):
if decorator.has_credentials():
# do something
else:
url = decorator.authorize_url()
self.response.out.write(template.render('templates/index.html',
{'authorize_url': url}))
Run Code Online (Sandbox Code Playgroud)
最后,我读到了另一种方法:
user = users.get_current_user()
if user:
# do something
else:
greeting = ("<a href=\"%s\">Sign in or register</a>." %
users.create_login_url("/"))
self.response.out.write("<html><body>%s</body></html>" % greeting)
Run Code Online (Sandbox Code Playgroud)
处理用户身份验证以满足我的需求的最佳方法是什么(请参阅更新)?
提前谢谢了
google-app-engine oauth-2.0 python-2.7 app.yaml google-api-python-client
我想要一个用于获取Google+主页的脚本.我使用谷歌的 脚本.client-secrets.json文件是:
{
"web": {
"client_id": "##########",
"client_secret": "############",
"redirect_uris": ["http://localhost:8080/oauth2callback/"],
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"client_email":"##########@developer.gserviceaccount.com",
"javascript_origins":["http://localhost:8080/"]
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我想启动这个应用程序时,它会打开一个错误和破坏机器人的页面:
The redirect URI in the request: http://localhost:8080/ did not match a registered redirect URI
请帮我解决我的问题.
我使用的是Google OAuth2身份验证,其中包括以下范围:
https://www.googleapis.com/auth/plus.login
Run Code Online (Sandbox Code Playgroud)
这允许我的应用程序访问用户的Google plus帐户信息(基本).
是否可以使用"
是",如何获取用户"圈子"的列表google-api-python-client?
注意:我不是使用Google+域名API,而是使用Google Plus API v1
python google-app-engine google-api google-plus google-api-python-client
我正在使用PyDrive QuickStart脚本列出我的Google Drive文件.
码:
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
file_list = drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList()
print(file_list)
Run Code Online (Sandbox Code Playgroud)
我能够正常列出我的文件,但是我需要从我已经过身份验证的GoogleDrive帐户列出并管理来自另一个公共驱动器URL(不是我个人认证的驱动器)的文件,就像我使用请求lib一样.有什么想法怎么做?
以下代码示例演示如何创建MIME消息,对base64url字符串进行编码,并将其分配给Message资源的raw字段:
def create_message(sender, to, subject, message_text):
"""Create a message for an email.
Args:
sender: Email address of the sender.
to: Email address of the receiver.
subject: The subject of the email message.
message_text: The text of the email message.
Returns:
An object containing a base64url encoded email object.
"""
message = MIMEText(message_text)
message['to'] = to
message['from'] = sender
message['subject'] = subject
return {'raw': base64.urlsafe_b64encode(message.as_string())}
Run Code Online (Sandbox Code Playgroud)
但是,如果我做了类似的事情
from email.MIMEText import MIMEText
import base64
message = MIMEText('This is a …Run Code Online (Sandbox Code Playgroud) python encoding python-3.x google-api-python-client gmail-api
我正在尝试将服务器连接到Google的API,但始终收到以下错误。
google.auth.exceptions.RefreshError: ('invalid_scope: h is not a valid audience string.', u'{\n "error" : "invalid_scope",\n "error_description" : "h is not a valid audience string."\n}')
我环顾四周,但似乎无法理解为什么Google提供的代码给了我这个错误。我认为这是我的service.json的问题,但我无法查明它是什么。
这是代码,几乎没有什么变化,这是从Google那里刷下来的。
from google.oauth2 import service_account
import googleapiclient.discovery
SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
SERVICE_ACCOUNT_FILE = 'service.json'
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
drive = googleapiclient.discovery.build('drive', 'v3', credentials=credentials)
response = drive.files().list(
pageSize=10,fields="nextPageToken, files(id, name)").execute()
print(response)
Run Code Online (Sandbox Code Playgroud)
我想做的是使用Google API将电子表格自动下载到本地,可能每小时一次,无需用户验证。
前言:Python 非常新,但感谢您的帮助!
下面是一个代码片段,我试图在其中对 MSSQL 服务器表执行 SQL 查询,然后将其发回 Google 表格。我能够检索数据和标题,我想我几乎已经弄清楚了。但是,我在使用某些列的日期时间格式时遇到了一些麻烦。我收到的错误是:
Traceback (most recent call last):
File "modelhome.py", line 153, in <module>
valueInputOption=value_input_option, insertDataOption=insert_data_option, body=value_range_body)
File "C:\ProgramData\Anaconda3\lib\site-packages\googleapiclient\discovery.py", line 785, in method
actual_path_params, actual_query_params, body_value)
File "C:\ProgramData\Anaconda3\lib\site-packages\googleapiclient\model.py", line 151, in request
body_value = self.serialize(body_value)
File "C:\ProgramData\Anaconda3\lib\site-packages\googleapiclient\model.py", line 260, in serialize
return json.dumps(body_value)
File "C:\ProgramData\Anaconda3\lib\json\__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "C:\ProgramData\Anaconda3\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\ProgramData\Anaconda3\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "C:\ProgramData\Anaconda3\lib\json\encoder.py", line 180, …Run Code Online (Sandbox Code Playgroud) python pyodbc pandas google-api-python-client google-sheets-api
python ×8
oauth-2.0 ×3
google-api ×2
api ×1
app.yaml ×1
encoding ×1
gmail-api ×1
google-plus ×1
pandas ×1
pydrive ×1
pyodbc ×1
python-2.7 ×1
python-3.x ×1