以下是我提出的要求: -
// create new entry
$doc = new DOMDocument();
$doc->formatOutput = true;
$entry = $doc->createElement('atom:entry');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:atom', 'http://www.w3.org/2005/Atom');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gd', 'http://schemas.google.com/g/2005');
$doc->appendChild($entry);
$cat = $doc->createElement('atom:category');
$cat->setAttribute('scheme', 'http://schemas.google.com/g/2005#kind');
$cat->setAttribute('term', 'http://schemas.google.com/contact/2008#contact');
$entry->appendChild($cat);
// add name element
$name = $doc->createElement('gd:name');
$entry->appendChild($name);
$givenName = $doc->createElement('gd:givenName', $_POST['fname']);
$familyName = $doc->createElement('gd:familyName', $_POST['lname']);
$fullName = $doc->createElement('gd:fullName', $_POST['fname'] . $_POST['lname']);
$name->appendChild($givenName);
$name->appendChild($familyName);
$name->appendChild($fullName);
$content = $doc->createElement('atom:content', 'Notes');
$content->setAttribute('type', 'text');
$entry->appendChild($content);
// add email element
$email = $doc->createElement('gd:email');
$entry->appendChild($email);
$email->setAttribute('address', $_POST['email_id']);
$email->setAttribute('displayName', $_POST['fname']);
$email->setAttribute('primary', 'true');
$email->setAttribute('rel', 'http://schemas.google.com/g/2005#work'); …Run Code Online (Sandbox Code Playgroud) 我已经部署了Google+登录按钮,现在我必须提供注销按钮,在此之前,我需要知道用户是否仍然已登录,然后我可以通过该按钮显示或隐藏此按钮.
我找到了这个文档:gapi.auth.checkSessionState(sessionParams,callback):https: //developers.google.com/+/web/api/javascript?hl = en #gapiauthchecksessionstatesessionparams_callback
有人可以演示如何使用它吗?
非常感谢.
如何通过 GMAIL API 使用 BCC 发送电子邮件?我向 TO 或 CC 发送电子邮件,但 BCC 不起作用。我使用Base64.urlsafe_encode64(email.to_s)此代码创建没有 BCC 的字符串。我的工作代码示例:
email = Mail.new
email.date = Time.now
email.subject = subject
email.to = email_array_to_email_to(to)
email.cc = email_array_to_email_to(cc)
email.bcc = email_array_to_email_to(bcc)
email.reply_to = email_array_to_email_to(reply_to)
email.html_part do
body message
end
request = {
api_method: @google_api.users.messages.to_h['gmail.users.messages.send'],
parameters: { userId: 'me' },
body_object: {
raw: Base64.urlsafe_encode64(email.to_s)
},
}
Run Code Online (Sandbox Code Playgroud)
我是否必须再次调用 GMAIL API 并使用线程 ID 和密件抄送作为 TO 发送此电子邮件?我使用google-api-client 0.7.1
编辑:邮件对象:
#<Mail::Message:70336725981360,
Multipart: true,
Headers: <Date: Tue,
01 Dec 2015 14:09:08 +0100>, …Run Code Online (Sandbox Code Playgroud) 是否可以通过 python 的 googleapiclient 模块显式移动文件?我想创建以下函数,给定文件、原始路径和目标路径:
def move_file(service, filename, init_drive_path, drive_path, copy=False):
"""Moves a file in Google Drive from one location to another.
service: Drive API service instance.
filename (string): full name of file on drive
init_drive_path (string): initial file location on Drive
drive_path (string): the file path to move the file in on Drive
copy (boolean): file should be saved in both locations
Returns nothing.
"""
Run Code Online (Sandbox Code Playgroud)
目前我一直通过手动下载文件然后将其重新上传到所需位置来执行此操作,但是这对于大文件来说并不实用,无论如何似乎都是一种解决方法。
编辑请参阅下面的解决方案:
I created a android app which is linked to Firebase . But i forgot to give package name so by default it took "com.example.abc.appname" . Here the problem is when i am uploading app in google playstore its not accepting release apk with generated with that file name.
我有一个 Java 后端(spring + google-oauth-client),它应该能够访问 Google.sheets 并从那里解析一些数据。
首先,我在本地后端部署上实现了常规的“三足”OAuth 2.0 身份验证,它工作得很好,但由于后端将部署在没有任何浏览器的云中,因此这不是最好的选择。
所以我决定使用服务帐户OAuth流程:创建谷歌服务帐户并重构我的代码以使用它而不是AuthCodeFlow,但我看到403 Forbidden“调用者没有权限”。据我所知,服务帐户不是谷歌的“我”,所以我必须让它访问“我的”帐户上的该工作表,但我不能这样做,因为我公司的政策禁止与他人共享文档我们的域,并且由于服务帐户具有 @myprject.iam.gserviceaccount.com 域,我无法授予对其的访问权限。
也许有一种方法可以解决这个问题,因为该服务帐户是从我的帐户创建的,该帐户拥有该工作表的所有者访问权限?如果不是,在这种情况下(无需用户参与)服务器到服务器 OAuth 的最佳方法是什么?
ps 我可以尝试与我的服务台联系,询问他们是否可以将此 gserviceaccount.com 添加到白名单等,但这将花费相当多的时间,而且结果也不能保证。
谢谢!
google-api oauth-2.0 google-api-client google-oauth service-accounts
我无法从 Rails 访问 Google Analytics API。即使我已经设置了服务帐户,我仍然获得足够的权限。
我创建了一个服务帐户:
拥有服务帐户并拥有秘密 JSON 文件和电子邮件后。然后我去谷歌分析:
一旦我有了这个,几乎可以使用以下代码: https: //gist.github.com/CoryFoy/9edf1e039e174c00c209e930a1720ce0来获取报告。
但我不断得到forbidden: User does not have sufficient permissions for this profile。即使当我尝试获取 access_token 并在 javascript 中使用它时:
gapi.analytics.auth.authorize({
serverAuth: {
access_token: 'accessToken'
}
});
Run Code Online (Sandbox Code Playgroud)
我得到:
error:{
code: 403
errors: [
{
domain: "global"
message: "User does not have sufficient permissions for this profile."
reason: "insufficientPermissions"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?这曾经有效,我从来没有遇到过问题,但由于某种原因它停止工作了。任何指导将不胜感激。
谢谢你! …
javascript google-analytics ruby-on-rails google-api-client google-analytics-4
我正在使用 google-api-php-client 从客户端 0auth 流请求访问令牌,但它返回错误“无法从请求确定客户端 ID”。
我的代码如下。
我的 client_secret.json:
"web": {
"client_id":"123",
"project_id":"1234",
"auth_uri":"https://accounts.google.com/o/oauth2/auth",
"token_uri":"https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
"client_secret":"123456789",
"redirect_uris":[
"http://localhost:7777/v1/oauth2callback"
],
"javascript_origins":[
"http://localhost:7777"
]
}
}
Run Code Online (Sandbox Code Playgroud)
我的身份验证 URL 创建:
$client->setAuthConfig(base_path() . '/client_secret.json');
$client->addScope(\Google_Service_Calendar::CALENDAR);
$client->setRedirectUri(URL::to('/') . '/v1/oauth2callback');
$client->setAccessType('offline');
$client->setPrompt('consent');
$client->setIncludeGrantedScopes(true);
$url = $client->createAuthUrl();
print filter_var($url, FILTER_SANITIZE_URL);
Run Code Online (Sandbox Code Playgroud)
然后我手动转到 URL:
身份验证流程似乎一切正常,并将我返回到我尝试解码令牌的网址:
$code = $request->code;
$client = new Google\Client();
$accessToken = $client->fetchAccessTokenWithAuthCode($code);
var_dump($accessToken);
exit;
Run Code Online (Sandbox Code Playgroud)
这给了我这个错误:
array(2) { ["error"]=> string(15) "invalid_request" ["error_description"]=> string(43) "无法根据请求确定客户端 ID。" }
google-api google-api-client google-oauth google-api-php-client
你好 !
我已经看到了很多类似的问题,但无法弄清楚为什么它们都没有给出明确的答案.
我正在尝试使用google-api-client gem连接到youtube数据api,以从youtube视频链接中检索缩略图.我假设我不需要处理(模糊我)oAuth身份验证.
它给了我一个客户ID,电子邮件地址和公钥指纹.
第二:我使用google-api-client gem创建我的ruby脚本.我只是复制/粘贴文档中的示例:
要求'google/api_client'
client = Google :: APIClient.new
从我的客户端对象我以为我可以直接调用client.execute()来获取我的所有视频信息的原子提要.但我只是想知道如何做到这一点.
也许我还得获得oAuth授权?要获得令牌?
我错过了什么?
非常感谢您的贡献.
我正在尝试在我的应用中使用Place Autocomplete API.我有一个主要的Activity.我有一个是Fragment其中的一部分MainActivity.在OnViewCreated()此Fragment.
private void rebuildGoogleApiClient() {
// When we build the GoogleApiClient we specify where connected and connection failed
// callbacks should be returned and which Google APIs our app uses.
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.enableAutoManage(activity, 0 /* clientId */, this)
.addConnectionCallbacks(this)
.addApi(Places.GEO_DATA_API)
.build();
}
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪:
Caused by: java.lang.IllegalStateException: Recursive entry to executePendingTransactions
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1471)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:488)
at com.google.android.gms.common.api.zzl.zza(Unknown Source)
at com.google.android.gms.common.api.GoogleApiClient$Builder.zzkL(Unknown Source)
at com.google.android.gms.common.api.GoogleApiClient$Builder.build(Unknown Source)
at com.app.projectpapri.Fragments.LocationScreen.rebuildGoogleApiClient(LocationScreen.java:69)
at …Run Code Online (Sandbox Code Playgroud) android google-api-client android-fragments google-places-api
google-api ×3
android ×2
google-oauth ×2
oauth-2.0 ×2
ruby ×2
firebase ×1
gmail ×1
gmail-api ×1
google-plus ×1
javascript ×1
oauth ×1
php ×1
python ×1
youtube-api ×1