我想使用google ruby API客户端进行相当于例如此API资源管理器调用.
这应该是简单的:
require 'rubygems'
require 'google/api_client'
require 'httpadapter/adapters/net_http'
@client = Google::APIClient.new(
:key => MY_SIMPLE_API_SERVER_KEY,
:host => 'www.googleapis.com',
:http_adapter => HTTPAdapter::NetHTTPAdapter.new,
:pretty_print => false
)
@plus = @client.discovered_api('plus', 'v1')
status, headers, body = @client.execute(
@plus.people.list_by_activity,
'activityId' => 'z12nspyxxufislit423eex442zqpdtqnk',
'collection' => 'plusoners',
'maxResults' => '100',
'authenticated' => 'false'
)
public_activity = JSON.parse(body[0])
Run Code Online (Sandbox Code Playgroud)
但是,这个execute电话会导致ArgumentError: Missing access token.
我不希望登录用户; 我只想访问公共数据.我该怎么做呢?
我收到了google-api-ruby-client的以下错误:
NameError: uninitialized constant Google::APIClient::PKCS12
NameError: uninitialized constant Google::APIClient::JWTAsserter
Run Code Online (Sandbox Code Playgroud)
这是我的代码的概要:
require 'google/api_client'
class Commissions::GoogleAffiliateNetwork < ActiveRecord::Base
def self.path_to_key_file
Rails.root + 'config/xxx-privatekey.p12'
end
def self.passphrase
'supersecretphrase'
end
def self.service_email
'42@developer.gserviceaccount.com'
end
def api_auth_uri
'https://www.googleapis.com/auth/gan'
end
def self.make_request(opts = {})
key = Google::APIClient::PKCS12.load_key(path_to_key_file, passphrase)
asserter = Google::APIClient::JWTAsserter.new(service_email, api_auth_uri, key)
api_client = Google::APIClient.new
api_client.authorization = asserter.authorize()
end
end
Run Code Online (Sandbox Code Playgroud)
在Gemfile中:
gem 'google-api-client'
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
在我们的网站http://www.draw.io/右上角有一个Google Drive集成按钮,它使用JS API客户端库进行授权.这在除了iOS 6上的Safari之外的任何地方都可以正常工作.当点击它时,新选项卡会短暂地弹回然后消失.从我们的日志记录中调用了我们的授权调用,但是从未到达我们的回调函数.
我们按照此主题中的提示来获得合理级别的多个帐户处理工作,并且它在我们测试过的所有其他环境中都能正常工作,包括iOS 5.如果我们在gapi.auth.authorize调用中将immediate参数设置为true 登录适用于iOS 6,因为可以避免弹出窗口.但是,这仅适用于拥有一个Google帐户的用户,如果他们有多个帐户,则会始终使用其默认帐户.
如果,当你读到这个问题时,主站点没有显示这种行为,那么我们可能已修补它以检测iOS 6上的Safari并将立即标志设置为true.这样可以解决问题的一部分,所以在iOS 6用户可以与我们的应用程序使用的驱动器在所有的,但我们仍然需要支持多个帐户.
好吧,我花了2个小时在谷歌上搜索它是什么以及如何在网络应用程序中使用它!但没有成功.
大多数链接都会讨论扫描代码或在GoogleAuthenticar移动应用中输入一些密钥,它会每30秒返回一次更改验证码.
一些事情 :
我很困惑,如果它是一个非谷歌非Android应用程序,它怎么能以一种方式实现!
我得到的只是,这只是一个概念,要求我们自己的实现,并在GoogleAuthenticator的源代码中提供一些帮助.请纠正我?
我认为这是解决的办法是,我们必须写我们自己的移动应用,就像提到的这个家伙在这里,但我仍然不知道如何将移动应用与服务器之间的秘密将是独一无二的,每个安装该应用程序,以便它只识别特定用户或有没有办法编写我们自己的应用程序并使用GoogleAuthenticator移动应用程序而无需在我们的webapp中登录Google?
oauth google-api google-authentication google-api-client google-authenticator
我正在创建一个cocoapod.到.podspec我添加了这一行:
cs.dependency 'Google-API-Client', '~> 1.0'
Run Code Online (Sandbox Code Playgroud)
从那时起,我无法将我的框架推向spec repo.中
pod repo push company-private MyFramework.podspec --allow-warnings --verbose
Run Code Online (Sandbox Code Playgroud)
我可以看到以下问题:
ERROR | [MyFramework/Core] Google-API-Client/Source/Objects/GTLService.m:86:1: error: duplicate interface definition for class 'GTMHTTPUploadFetcher'
Run Code Online (Sandbox Code Playgroud)
我不知道如何解决它.尝试:
sudo rm -fr ~/Library/Caches/CocoaPods/
sudo rm -fr ~/.cocoapods/repos/master/
sudo rm -fr Pods/
Run Code Online (Sandbox Code Playgroud)
但这没有帮助.这似乎是Google-API-Client的错误,但他们的响应时间是如此之大(等待上一张票的大约6个月,仍未解决),我等不了多久.任何人都知道如何跳过这个问题?在我的机器上本地构建确实有效.
我正在开发一个Android应用,并按照以下教程添加了Google登录功能:https://developers.google.com/identity/sign-in/android/sign-in
现在用户已登录,我希望能够读取和写入他们的Google Spreadsheets.我查看了电子表格API并告诉您使用OAuth授权请求:https://developers.google.com/google-apps/spreadsheets/?hl = zh- CN
从登录页面教程:
Google登录按钮可对用户进行身份验证并管理OAuth 2.0流程,从而简化您与Google API的集成.
我正在尝试使用Google登录页面进行授权.我现在可以使用GoogleApiClient成功登录和退出我的Google帐户,因此我尝试添加以下代码来访问我在用户登录时调用的电子表格:
private class RetrieveFeedTask extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... urls) {
SpreadsheetService service = new SpreadsheetService("MySpreadsheetIntegration-v1");
try {
URL SPREADSHEET_FEED_URL = new URL(urls[0]);
SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
for (SpreadsheetEntry spreadsheet : spreadsheets) {
System.out.println(spreadsheet.getTitle().getPlainText());
}
} catch (ServiceException | IOException e) {
e.printStackTrace();
}
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
我用这行称呼它:
new RetrieveFeedTask().execute("https://spreadsheets.google.com/feeds/spreadsheets/private/full");
Run Code Online (Sandbox Code Playgroud)
但是在service.getFeed调用上我收到以下错误:
com.google.gdata.util.ParseException: Unrecognized content …Run Code Online (Sandbox Code Playgroud) 我正在使用谷歌的API客户端与Gmail API进行交互.假设我有一个草稿的不可变ID,我想发送相关的草稿.
我试过了:
service.users().drafts().send(
userId='me', id=draft_id).execute(http=http)
Run Code Online (Sandbox Code Playgroud)
这draft_id是我要发送的草稿的id,http是一个Http适用于其他请求的实例(因此它经过了适当的身份验证).
试着上面,我得到一个TypeError:
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/Users/mgilson/git/spider-web/app/pattern/handlers/ajax/email.py", line 77, in post
'success': int(client.send_draft(draft_id))
File "/Users/mgilson/git/spider-web/app/pattern/services/email/gmail.py", line 601, in send_draft
userId='me', id=draft_id) \
File "/Users/mgilson/git/spider-web/app/third_party/googleapiclient/discovery.py", line 669, in method
raise TypeError('Got an unexpected keyword argument "%s"' % name)
TypeError: Got an unexpected keyword argument "id"
Run Code Online (Sandbox Code Playgroud)
该文档有一个Java示例,但没有python示例.
我试过的其他变化:
service.users().drafts().send(
userId='me', draftId=draft_id).execute(http=http)
service.users().drafts().send(
userId='me', draft_id=draft_id).execute(http=http)
service.users().drafts().send( …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的应用程序连接到Google Play服务以访问Google云端硬盘,但它显示我与statusCode的连接失败SIGN_IN_REQUIRED.
但它似乎就在3天前表现得那样.我也检查了谷歌的开发者控制台.他们可能在API中改变了一些我无法弄清楚的东西.欢迎您的帮助.
我的代码:
/**
* Create a new file and save it to Drive.
*/
private void saveFileToDrive(final byte[] data) {
// Start by creating a new contents, and setting a callback.
Log.i(TAG, "Creating new contents.");
//final Bitmap image = mBitmapToSave;
Drive.DriveApi.newDriveContents(mGoogleApiClient)
.setResultCallback(new ResultCallback<DriveApi.DriveContentsResult>() {
@Override
public void onResult(DriveApi.DriveContentsResult result) {
// If the operation was not successful, we cannot do anything
// and must
// fail.
if (!result.getStatus().isSuccess()) {
Log.i(TAG, "Failed to create new contents.");
return; …Run Code Online (Sandbox Code Playgroud) android google-api google-api-client google-drive-android-api android-googleapiclient
今天我想出了一些谷歌新产品"太空"的想法.我搜索了很多,但找不到任何迹象表明这个应用程序有API.
你有关于这个主题的信息吗?
我正在尝试按照本教程进行操作:https://developers.google.com/drive/v3/web/quickstart/python#step_1_turn_on_the_api_name
但是,当我运行它时,我收到以下错误:
Traceback (most recent call last):
File "test.py", line 5, in <module>
from apiclient import discovery
File "/Library/Python/2.7/site-packages/apiclient/__init__.py", line 16, in <module>
from googleapiclient import channel
File "/Library/Python/2.7/site-packages/googleapiclient/channel.py", line 62, in <module>
from googleapiclient import errors
File "/Library/Python/2.7/site-packages/googleapiclient/errors.py", line 25, in <module>
from oauth2client import util
ImportError: cannot import name util
Run Code Online (Sandbox Code Playgroud)
我已经尝试使用我所阅读的Google API版本1.3.2可能会解决问题,但它似乎没有改变任何东西.
我对Python很新.
google-api ×5
android ×2
python ×2
api ×1
cocoapods ×1
gmail-api ×1
google-plus ×1
ios ×1
ios6 ×1
java ×1
oauth ×1
objective-c ×1
safari ×1