为了测试我们的应用程序,我需要插入/更新谷歌日历事件并验证边缘情况,比如会议邀请是否超过 30 天,它不应该显示给最终用户。我正在为单个 gmail id testaccount@.com 进行此设置,并尝试操纵事件以涵盖所有边缘情况。
按照此链接 - https://developers.google.com/calendar/v3/reference/events/insert
1)我创建了一个新项目https://console.cloud.google.com。
2) 启用谷歌日历 API
3)为credentials.json设置OAuth客户端
4) 运行 python 快速启动以获得 10 个日历事件 - 验证步骤 3 是否正确。
5)现在在同意屏幕上插入添加以下范围的事件 https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/calendar.events
6) 重新生成凭证,使其具有新添加的插入事件的范围。
我收到以下错误消息 - 请求https://www.googleapis.com/calendar/v3/calendars/primary/events?alt=json时出现 HttpError 403返回“权限不足:请求的身份验证范围不足”。
我也尝试过使用电子邮件 ID 代替“primay”,但最终还是出现了同样的错误。
我在调用 Google Play Developer API 时遇到问题。
我已按照https://developers.google.com/android-publisher/authorization 上列出的所有步骤进行操作。这包括
然后,为了调用 purchase.subscriptions.get API,我使用了以下 CURL 命令:
(https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions/get)
curl -X GET "https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}" -H "Authorization: Bearer {access_token}" -H "Accept: application/json" --compressed
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误:
"error": {
"code": 401,
"message": "The …Run Code Online (Sandbox Code Playgroud) 我有一个kitkat api的问题,同时tringy获取谷歌帐户服务的访问令牌,在我的情况下谷歌音乐.因此,如果用户首先使用next方法尝试获取令牌:
public String getAuthToken(Account account)
throws AuthenticatorException, IOException {
String s1;
if (account == null) {
Log.e("MusicAuthInfo", "Given null account to MusicAuthInfo.getAuthToken()", new Throwable());
throw new AuthenticatorException("Given null account to MusicAuthInfo.getAuthToken()");
}
String s = getAuthTokenType(mContext);
try {
s1 = AccountManager.get(mContext).blockingGetAuthToken(account, s, true);
} catch (OperationCanceledException operationcanceledexception) {
throw new AuthenticatorException(operationcanceledexception);
}
if (s1 == null) {
throw new AuthenticatorException("Received null auth token.");
}
return s1;
}
Run Code Online (Sandbox Code Playgroud)
在这里,我得到s1 == null和系统推送通知:

当用户点击通知时,会出现下一个对话框:

当用户单击"确定"时,获取令牌的所有下一次迭代都会成功.
问题:如何绕过此确认或仅显示对话框,而不点击通知?
我有一个谷歌加登录设置为应用程序通过GoogleApiClient.
每当应用程序第一次安装并尝试通过GoogleApiClient它进行连接时,永远不会成功并始终onConnectionFailed以result包含:
ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{4130e760: android.os.BinderProxy@4130e700}}
Run Code Online (Sandbox Code Playgroud)
但是当第二次登录时,它被称为成功并onConnected点击.为什么有可能在第一次尝试中取得成功?
我的Builder参数有问题吗?
public void connectGoogleApi() {
mGoogleApiClient = new GoogleApiClient.Builder(mainAppContext).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN).build();
mGoogleApiClient.connect();
}
public void onConnectionFailed(ConnectionResult result) {
if (!result.hasResolution()) {
GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, 0).show();
return;
}
if (!mIntentInProgress) {
// Store the ConnectionResult for later usage
mConnectionResult = result;
resolveSignInError();
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用JavaScript通过Google API发送电子邮件.
我的问题是,当我尝试发送没有附件的简单邮件时,我收到以下错误:
'raw'RFC822有效负载消息字符串或上传消息via/upload/*URL required`
我的代码
function sendMessage() {
gapi.client.load('gmail', 'v1', function() {
// Web-safe base64
var to = 'someone@someone.nl',
subject = 'Hello World',
content = 'send a Gmail.'
var base64EncodedEmail = btoa(
"Content-Type: text/plain; charset=\"UTF-8\"\n" +
"Content-length: 5000\n" +
"Content-Transfer-Encoding: message/rfc2822\n" +
"to: someone@someone.nl\n" +
"from: \"test\" <test@gmail.com>\n" +
"subject: Hello world\n\n" +
"The actual message text goes here"
).replace(/\+/g, '-').replace(/\//g, '_');
var mail= base64EncodedEmail;
console.log(mail);
var request = gapi.client.gmail.users.messages.send({
'userId': "me",
'message': {
'raw': mail
}
});
request.execute(function(response){ …Run Code Online (Sandbox Code Playgroud) 我想要为了登录用户我必须使用这段代码:
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
Run Code Online (Sandbox Code Playgroud)
注销
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
disconnect();
}
});
Run Code Online (Sandbox Code Playgroud)
但是当用户重新启动应用程序并且他已经登录(之前没有退出)是否可以检测到这个"当前登录"状态?
显然,可以将"登录"保存在应用程序的设置(共享首选项)中,但是可以使用google api进行检测吗?
android google-api-client android-googleapiclient google-signin googlesigninapi
这两个库之间有什么区别?我应该使用哪一个进行身份验证?
例如:我看到虽然一个包含 setCredentials,但另一个不支持它。并有凭据作为财产
我无法理解为什么这个非常简单的活动会产生内存泄漏.
它遵循此处给出的指导原则:https://developer.android.com/training/location/receive-location-updates.html以及此处给出的示例代码:https://github.com/googlesamples/android-play-location /树/主/ LocationUpdates
我还注意到,如果我不重写LocationCallback类的onLocationResult方法,则会解决内存泄漏问题.但就这种方式而言,LocationCallback完全没用.
谢谢您的帮助!
public class TestLeaks extends Activity {
private FusedLocationProviderClient mFusedLocationClient; // Access to Fused Loc. Provider API
private LocationRequest mLocationRequest; // Stores parameters for requests to F.L.P.Api
private LocationCallback mLocationCallback; // Callback for Location events
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_leaks);
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
super.onLocationResult(locationResult);
Location loc = locationResult.getLastLocation();
((TextView) findViewById(R.id.latitude)).setText(String.format(Locale.US, "%.6f", loc.getLatitude()));
((TextView) findViewById(R.id.longitude)).setText(String.format(Locale.US, …Run Code Online (Sandbox Code Playgroud) android memory-leaks google-api-client location-updates fusedlocationproviderclient
我最近在我的 Raspberry Pi 3 b+(运行版本 9 [Stretch])上安装了 PyCharm,但在 PyCharm 和系统上安装 googleapiclient 包时遇到了一些问题。
当我为此包执行 pip/pip3 安装时,我收到一条错误消息:
错误:找不到满足 googleapiclient 要求的版本(来自版本:无)
错误:找不到与 googleapiclient 匹配的发行版
这与我在 PyCharm 上尝试执行 pip 安装时收到的错误消息相同。Python 3.7.3 已安装,默认安装为 2.7.13。PyCharm 项目解释器正在运行 3.5。我也执行了 apt-get 更新和升级。
我也能够使用 pip/pip3 成功安装其他软件包。
我是否缺少任何其他包/依赖项?
Google Calender Node.js 示例需要一个名为“credentials.json”的文件:https : //developers.google.com/calendar/quickstart/nodejs
相关代码:
// Load client secrets from a local file.
fs.readFile('credentials.json', (err, content) => {
if (err) return console.log('Error loading client secret file:', err);
// Authorize a client with credentials, then call the Google Calendar API.
authorize(JSON.parse(content), listEvents);
});
function authorize(credentials, callback) {
const {client_secret, client_id, redirect_uris} = credentials.installed;
const oAuth2Client = new google.auth.OAuth2(
client_id, client_secret, redirect_uris[0]);
// Check if we have previously stored a token.
fs.readFile(TOKEN_PATH, (err, token) => {
if (err) return …Run Code Online (Sandbox Code Playgroud) android ×5
google-api ×5
google-oauth ×2
node.js ×2
email ×1
fusedlocationproviderclient ×1
javascript ×1
memory-leaks ×1
pycharm ×1
python ×1