我正在使用 PHP Google 客户端库。我成功从 user/google 获取了令牌并刷新令牌以与 API 一起使用。一旦用户在 Google 页面上的 Google 设置中撤销我的网站的权限,我就会收到以下错误:
Error calling GET https://www.googleapis.com/calendar/v3/users/me/calendarList: (401) Invalid Credentials
Run Code Online (Sandbox Code Playgroud)
这是预期的行为,因为用户撤销了我的许可。但是,如何检测用户撤销了该访问权限?
目前我执行以下操作来查看我是否有权访问:
//$token json fetched from database
$gclient->setAccessToken($token);
if ($gclient->getAccessToken())
//i should have access
Run Code Online (Sandbox Code Playgroud)
不幸的是,这段代码没有检测到撤销的权限。我该如何处理?
我正在尝试使用电话选择器 API 获取电话号码,但得到空响应,这是我的代码。
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
.addApi(Auth.CREDENTIALS_API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
googleApiClient.connect();
HintRequest hintRequest = new HintRequest.Builder()
.setPhoneNumberIdentifierSupported(true)
.build();
PendingIntent intent = Auth.CredentialsApi.getHintPickerIntent(
googleApiClient, hintRequest);
try {
startIntentSenderForResult(intent.getIntentSender(),
RESOLVE_HINT, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESOLVE_HINT) {
if (resultCode == RESULT_OK) {
Credential credential = data.getParcelableExtra(Credential.EXTRA_KEY);
// credential.getId(); <-- will need to process phone number string
}
} …Run Code Online (Sandbox Code Playgroud) 这是我的代码:
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->addScope("email");
$client->addScope("profile");
$service = new Google_Service_Oauth2($client);
$user = $service->userinfo->get(); //get user info
echo "<pre>";
print_r($user);
die;
Run Code Online (Sandbox Code Playgroud)
结果是:
/*
Google_Service_Oauth2_Userinfoplus Object
(
[internal_gapi_mappings:protected] => Array
(
[familyName] => family_name
[givenName] => given_name
[verifiedEmail] => verified_email
)
[email] => MyEmailName@gmail.com
[familyName] => Martinish
[gender] =>
[givenName] => Martin
[hd] =>
[id] => 11150231528512531xxx
[link] => https://plus.google.com/111502315285125311xxx
[locale] => en
[name] => Martin Martinish
[picture] => https://lh5.googleusercontent.com/-fVHMRUGw5z4/xxx/xxx/IhHnvxaOyAw/photo.jpg
[verifiedEmail] => 1
[modelData:protected] => Array
(
[verified_email] …Run Code Online (Sandbox Code Playgroud) 正如在此 SO线程中所解释的那样,无法使用 People API 获取“其他联系人”。我想知道 Google 是否打算这样做?例如,由于 Go 不支持 Contacts API 而只支持 People API,这意味着我们将失去访问其他联系人的可能性,这对于使用 Google 联系人的应用程序中的自动完成功能来说非常烦人..谢谢!
我想将照片上传到谷歌驱动器。我可以读取驱动器上的文件。但是当我为上传部分添加广告时,从第 49 行到第 55 行,我不断收到相同的错误。我不断收到错误“NameError: name 'drive_service' is not defined” 我已经导入了每个库,但仍然无法工作 这是我环顾四周的代码,但还没有看到解释它的帖子。
from __future__ import print_function
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
from apiclient.http import MediaFileUpload
# If modifying these scopes, delete the file token.json.
SCOPES = 'https://www.googleapis.com/auth/drive'
def main():
"""Shows basic usage of the Drive v3 API.
Prints the names and ids of the first 10 files the user has access to."""
# The file token.json stores the user's access and …Run Code Online (Sandbox Code Playgroud) 对于一个项目,我正在创建一个 Android 应用程序,其中包括 、WebView、service可以从后台切换到前台以及LocationManager依赖于NETWORK_PROVIDER第一个和GPS_PROVIDER后者。在非常随机的情况下,启动应用程序后,我在 logcat 输出中发现此异常:
E/GoogleApiClientConnecting: GoogleApiClient connecting is in step STEP_SERVICE_BINDINGS_AND_SIGN_IN but received callback for step STEP_GETTING_REMOTE_SERVICE
java.lang.Exception
at qw.b(PG:25)
at qw.c(PG:36)
at Iw.c(PG:3)
at Gx.c(PG:2)
at ly.d(PG:15)
at gy.a(PG:19)
at iy.c(PG:6)
at hy.handleMessage(PG:46)
at android.os.Handler.dispatchMessage(Handler.java:106)
at oG.dispatchMessage(PG:1)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:65)
Run Code Online (Sandbox Code Playgroud)
我检查了我的代码和依赖项,似乎没有任何与 GoogleApiClient 相关的内容(我发现它已经过时了)。我不(有意识地)使用 Google Play 商店集成或类似的东西。
这个异常似乎大大减慢了我的 WebView 的速度(每个 XHR 或 fetch 都停滞了几乎 3 秒)。我不知道这怎么可能有关系。
另外,它仅在启动或重新启动应用程序时偶尔发生(有时在清除所有数据后)。
任何帮助将不胜感激,这让我很烦恼。
我的应用程序生成一个数据表,并在用户的Google云端硬盘中创建一个新的电子表格文档.如何为单个单元格添加格式(颜色,字体粗细,宽度等)?我似乎无法找到任何文档,更不用说我可以通过它来实现这一点google-api-ruby-client.
我的大多数调查结果都追溯到Google API邮件列表,表明它不受支持.
但是,我发现另一个应用程序实现了我想要的结果.将文档导出到Google云端硬盘的"Smartsheet"示例:
来自Smartsheet.com:

在我的Google云端硬盘中生成的表单:

google-api google-sheets google-api-client google-drive-api google-sheets-api
我有一个node.js程序,我正在尝试使用googleapis模块(https://github.com/google/google-api-nodejs-client)版本0.2.5-alpha.
我可以毫无问题地使用原始HTTP进行调用,因此我知道我在API中列出了白名单,我正在进行身份验证和授权,并且正在请求正确的范围和所有内容.如果我使用相同的access_token在时间轴中插入,我在回调中收到错误.我也发现了plus API,使用这个API的调用工作正常.
用于发现API的代码片段,看起来没有问题:
var client;
googleapis
.discover( 'plus', 'v1' )
.discover( 'mirror', 'v1' )
.execute( function(err,data){
console.log( err );
client = data;
});
Run Code Online (Sandbox Code Playgroud)
执行调用的代码片段:
client.mirror.timeline.insert({
text: "test 1 "
} ).withAuthClient(user.auth).execute(function(err,result,res){
console.log( '++ start ++' );
console.log( '+err ', err );
console.log( '+result', result );
//console.log( '+res ', res );
console.log( '++ end ++' );
});
回调期间记录的内容:
++ start ++
+err { code: 400,
message: 'Required',
data: [ { domain: 'global', reason: 'required', message: 'Required' } ] … google-api-client google-mirror-api google-api-nodejs-client
是否可以使用Youtube API v3按标签搜索视频?我想在我自己的视频中搜索.
我有以下对象
HttpTransport t = AndroidHttp.newCompatibleTransport();
Run Code Online (Sandbox Code Playgroud)
但是整个AndroidHttp类(com.google.api.client.extensions.android.http.AndroidHttp)都被标记为已弃用。
我不知道使用较新的库替换它的类是什么。
如何替换这个过时的电话?
android google-api-java-client google-api-client android-httptransport
google-api ×5
android ×3
google-oauth ×1
oauth ×1
oauth-2.0 ×1
php ×1
python ×1
youtube-api ×1