我使用新的Gmail API为我的用户创建草稿.API响应提供新创建的消息ID.
然后我可以用URL打开撰写窗口https://mail.google.com/mail/#drafts?compose=[message-id].但是我想打开一个全屏(弹出)组合窗口.是否有URL?当然,必须使用消息ID对此URL进行参数化.
我今天刚刚创建了一个新的POC(关于活动转换,但这不是主题),我注意到在主要活动的"onCreate"方法中写了一个新行:
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
mClient = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
Run Code Online (Sandbox Code Playgroud)
和更多:
@Override
public void onStart() {
super.onStart();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
mClient.connect();
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"SinglePhotoViewer Page", // TODO: Define a title for the content shown.
// TODO: If you have web page content that matches …Run Code Online (Sandbox Code Playgroud) 关于"G Suite/Google Apps API"的可用性,我有几个问题.我想将某种文档/电子表格/演示文稿管理直接集成到我正在构建的应用程序中.
这项服务必须能够导入和导出到DOC/XLS/PPT/PDF等......所以像Feng Office这样的东西(如果你听说过的话)就不适合这种需要.
为此,我正在研究存在这样的事情.在我开始这项努力之前,我想知道:
对于问题的崩溃列表感到抱歉,但如果有人可以帮助解决这些问题,我们将不胜感激.
spryno724
google-api google-docs google-apps-script google-api-client google-drive-api
更新2:我重新审视了这个问题,并通过仔细遵循下面链接的doco解决了这个问题.但首先,对于那些正在努力解决这个问题的人来说,你们的团结良好.谷歌有很多版本的doco令人困惑!你在html中包含了platform.js或client.js吗?你加载gapi.auth或gapi.auth2?你使用gapi.auth2.render或gapi.auth.authorize,还是gapi.auth2.init等等.
返回access_token的方式(截至本文日期)在下面链接.我设法通过使用platform.js仔细遵循指南和参考来实现这一点.然后使用gapi.load('drive',callback)动态加载其他库,例如client.js.
https://developers.google.com/identity/sign-in/web/listeners https://developers.google.com/identity/sign-in/web/reference
====繁荣的原始问题====
更新1: 我已更新代码示例以对googleUser对象进行递归搜索.至少这不应该在随后的库中中断.
下面是一个代码片段,用于处理Google gapi.auth2.AuthResponse对象中的access_token不在顶层的问题...它被隐藏:(在对象的深处!
所以它是可以检索的,但不是顶级的!! 我注意到它似乎是一个计时问题...一旦应用程序在后续检查中运行了一段时间,它确实包含顶级访问令牌!
var authResponse = _.googleUser.getAuthResponse();
_.id_token = authResponse.id_token; // Always exists
// access_token should also be a param of authResponse
if (authResponse.access_token) {
debug("Worked this time?");
_.access_token = authResponse.access_token;
} else {
// !!! Internal object access !!!
debug("Attempt to get access token from base object.");
_.access_token = _.objRecursiveSearch("access_token", _.googleUser);
if (_.access_token) {
debug("Access token wasn't on authResponse but was on the base object, WTF?");
} else {
debug("Unable …Run Code Online (Sandbox Code Playgroud) 我正在尝试实现 SMS Retriever API 以进行 SMS 验证。文档中提到的官方方式说GoogleApiClient与HintRequest从设备检索手机号码一起使用
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();
}
Run Code Online (Sandbox Code Playgroud)
但是GoogleAPIClient已弃用并由GoogleApi接口代替,例如GoogleSignInClient. 我尝试使用GoogleSignInClient但getHintPickerIntent不接受。即使在被弃用后使用旧 API 是否安全,或者有没有办法将后者与 SMSRetriver API 一起使用?
android google-api google-api-client googlesigninapi sms-retriever-api
我正在使用Google API Client Library for JavaScript(Beta)在Web应用程序上授权用户google帐户(用于youtube操作).一切正常,但我不知道如何从我的应用程序"注销"用户,即重置访问令牌.
例如,以下代码检查用户授权,如果没有,则显示用户登录帐户的弹出窗口,并允许Web应用程序访问用户数据:
gapi.auth.authorize({client_id: CLIENT_ID, scope: SCOPES, immediate: false}, handleAuth);
Run Code Online (Sandbox Code Playgroud)
但客户端库没有重置授权的方法.
有一种解决方法可以将用户重定向到"accounts.google.com/logout",但这种方法不是我需要的:因此我们不仅从我的应用程序,而且从任何地方,从谷歌帐户注销用户.
Google常见问题解答和客户端库说明都没有帮助.
我正在通过JS使用谷歌登录,看来我的代码获取数据两次.我不确定为什么会这样.
当我点击"使用Google登录"按钮时,它会向用户吐出(console.log(result))数据.然后出现提示,要求我选择我的帐户(我登录了几个谷歌帐户).当我点击我想要的帐户时,代码会再次吐出该用户数据.
为什么会这样?这是一个问题,因为在我吐出数据的地方,我想做一个ajax调用来验证用户,然后重定向它们.所以从本质上说,它试图这样做两次 - 这并不酷,如果我不想使用凭据登录google在第一次转发时回传?
(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
function googleLogin() {
var additionalParams = {
'callback': googleCallback
};
gapi.auth.signIn(additionalParams);
}
function googleCallback(authResult) {
if (authResult['status']['signed_in']) {
gapi.client.load('oauth2', 'v2', function() {
gapi.client.oauth2.userinfo.get().execute(function(resp) {
console.log(resp);
})
});
} else {
console.log('Sign-in state: ' + authResult['error']);
}
}
Run Code Online (Sandbox Code Playgroud)
更新:如果我退出所有Google帐户(除了一个且只有一个),谷歌的调用仍然是重复的.这次它登录,我看到console.log()两次输出数据.访问令牌是相同的.
更新2: console.log(resp)输出两次
更新3:更多说明:

javascript google-api google-authentication google-api-client google-oauth
在我的机器上遇到一些SSL问题之后,我仍然试图通过Google Ruby Client API访问用户的Blogger帐户.我正在使用以下内容:
我可以在身份验证时通过Google API成功验证用户身份并访问他们的博客.当用户登录时,我会存储access_token并refresh_token从Google收到.一切都很好,直到access_token过期.我正在尝试构建交换refresh_token新功能的功能access_token,但不断遇到问题.以客户端文档为例,这是我正在使用的代码:
client = Google::APIClient.new
token_pair = auth.oauth_token # access_token and refresh_token received during authentication
# Load the access token if it's available
if token_pair
client.authorization.update_token!(token_pair.to_hash)
end
# Update access token if expired
if client.authorization.refresh_token && client.authorization.expired?
client.authorization.fetch_access_token!
end
blogger = client.discovered_api('blogger', 'v3')
result = client.execute(
api_method: blogger.blogs.list_by_user,
parameters: {'userId' => "self", 'fields' => …Run Code Online (Sandbox Code Playgroud) ruby-on-rails access-token oauth-2.0 omniauth google-api-client
如果用户伪造该位置,我将阻止用户使用我的应用.所以我isFromMockProvider用来检查位置是否是假的(按照这里).但isFromMockProvider()在某些情况下可能会为伪造的位置返回false.
public void onLocationChanged(Location location) {
textView.append("long:"+location.getLatitude()+" - lat:"+location.getLongitude()+" - isMock :"+location.isFromMockProvider() + "\n");
}
Run Code Online (Sandbox Code Playgroud)
我的情况是:我使用假冒伪劣GPS定位到一个位置然后我禁用虚假位置并转到我的应用程序.然后onLocationChanged返回假位置isFromMockProvider() = false
录像机:https://www.youtube.com/watch?v = rWVvjOCaZiI(在此视频中,我目前的位置是16.06,108.21,假位置是36.26,138.28.你可以在上一个视频中看到位置是36.26, 138.28但isFromMockProvider = false)
有没有办法检测用户在这种情况下是否使用虚假位置?任何帮助或建议将非常感谢.
DEMO项目
我正试图在我的Android游戏中使用Google Games回合制Api.我用来连接我的代码GoogleApiClient来自Google的Api示例或文档.
在我的实现中,onConnectionFailed我尝试了两种不同的方法:
if (signInClicked || autoStartSignInFlow) {
autoStartSignInFlow = false;
signInClicked = false;
resolvingConnectionFailure = true;
// Attempt to resolve the connection failure using BaseGameUtils.
// The R.string.signin_other_error value should reference a generic
// error string in your strings.xml file, such as "There was
// an issue with sign-in, please try again later."
if (!BaseGameUtils.resolveConnectionFailure(this,
apiClient, connectionResult,
RC_SIGN_IN, R.string.signin_other_error)) {
resolvingConnectionFailure = false;
}
}
Run Code Online (Sandbox Code Playgroud)
上面的第一种方法来自TBMP Skeleton样本.这会导致使用消息创建对话框
登录失败.请检查您的网络连接,然后重试.
并且永远不会建立联系.
if (connectionResult.hasResolution()) {
// https://developers.google.com/android/guides/api-client under …Run Code Online (Sandbox Code Playgroud) google-api ×6
android ×4
google-oauth ×2
oauth-2.0 ×2
access-token ×1
email ×1
gmail ×1
gmail-api ×1
google-docs ×1
gps ×1
java ×1
javascript ×1
location ×1
omniauth ×1