google / googleapis.dart Goto Github PK
View Code? Open in Web Editor NEWRepository for building the googleapis packages
Home Page: https://pub.dev/packages/googleapis
License: BSD 3-Clause "New" or "Revised" License
Repository for building the googleapis packages
Home Page: https://pub.dev/packages/googleapis
License: BSD 3-Clause "New" or "Revised" License
I was so close to finally integrate calendar API in my project and then:
type '_InternalLinkedHashMap' is not a subtype of type 'Map<String, List<String>>' where
_InternalLinkedHashMap is from dart:collection
Map is from dart:core
String is from dart:core
List is from dart:core
String is from dart:core
#0 ApiRequester.request (package:_discoveryapis_commons/src/clients.dart:66:47)
#1 CalendarsResourceApi.insert (package:googleapis/calendar/v3.dart:1157:32)
#2 CalendarServer.createSecondaryCalendar (package:memspace/src/services/calendar_server.dart:35:26)
#3 _createCalendar (package:memspace/src/middleware/auth.dart:154:33)
<asynchronous suspension>
...
I tried fetching a spreadsheet from Google Docs, I got a result back indicating the following error:
E/flutter ( 9786): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: DetailedApiRequestError(status: 403, message: Export requires alt=media to download the exported content.)
E/flutter ( 9786): #0 _validateResponse (package:_discoveryapis_commons/src/clients.dart:875:9)
E/flutter ( 9786):
E/flutter ( 9786): #1 ApiRequester.request (package:_discoveryapis_commons/src/clients.dart:69:22)
E/flutter ( 9786):
Code below:
clientViaServiceAccount(_credentials, _SCOPES).then((httpClient) {
var driveApi = CustomDriveApi(httpClient);
final spreadSheetId = '';
final mimeType = 'application/pdf';
driveApi.files
.exportWithAlt(spreadSheetId, mimeType, alt: 'media')
.then((document) => print(document));
});
Was playing around with the mimeTypes -(csv/text, applciation/pdf)
Hi,
I have a requirement that I need to run background processing that has to connect to Google Drive and Google Sheets for a set of gmail IDs. I didn't find any place where I could force a Google Signin using a specific gmail ID. In my native Android app, I could do this easily using the snippet below but this does not seem possible in Flutter using this package. Do you have any recommendations? Silent sign in also uses the last logged in gmail id. My requirement is to sign in for a set of gmail ids registered in my app.
// Initialize credentials and service object.
GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(
this, Arrays.asList(Const.SCOPES))
.setBackOff(new ExponentialBackOff());
credential.setSelectedAccount(new Account(gmailid,"com.test.myapp"));
The instructions for starting the development server are here:
https://cloud.google.com/datastore/docs/tools/devserver
What's unclear from the googleapis docs is if and how I can use it.
See dart-lang/dart-pad#385 for more details. We've worked around the issue in our client. We may want to move a more permanent fix into src/clients.dart/simpleRequest
or into the discoveryapis_generator
generated library?
With 0.50.1:
type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Map<String, String>' where
_InternalLinkedHashMap is from dart:collection
String is from dart:core
Map is from dart:core
String is from dart:core
String is from dart:core
#0 new EventExtendedProperties.fromJson (package:googleapis/calendar/v3.dart:4162:22)
#1 new Event.fromJson (package:googleapis/calendar/v3.dart:4635:15)
#2 new Events.fromJson.<anonymous closure> (package:googleapis/calendar/v3.dart:5163:38)
#3 MappedListIterable.elementAt (dart:_internal/iterable.dart:414:29)
#4 ListIterable.toList (dart:_internal/iterable.dart:219:19)
#5 new Events.fromJson (package:googleapis/calendar/v3.dart:5164:12)
#6 EventsResourceApi.list.<anonymous closure> (package:googleapis/calendar/v3.dart:1996:41)
#7 _RootZone.runUnary (dart:async/zone.dart:1381:54)
#8 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#9 <…>
I've often found the DetailedApiRequestError.jsonResponse
to contain critically important information about errors...
Maybe we could just dump that as part of the error messages using toString()
, if we pretty print it with indentation it probably doesn't matter so much if it's a huge blob.
I'm not entirely sure if any APIs would include sensitive information in error messages that you wouldn't want to risk leaking into logs. But I suspect that's not the case, although it can never be excluded as users could be doing anything..
Any plans to support beta3 of the datastore api?
Is there a reason for it?
How to create an HTTP Client starting from an GoogleSignInAccount.authHeaders
?
None of the below options seems to be fit for this scenario:
clientViaApiKey(apiKey)
clientViaMetadataServer()
clientViaServiceAccount(clientCredentials, scopes)
clientViaUserConsent(clientId, scopes, userPrompt)
clientViaUserConsentManual(clientId, scopes, userPrompt)
I'm facing issue using the googleapis package for Flutter/Dart. That's the code that I have...
import 'dart:convert';
import 'package:googleapis/gmail/v1.dart' as gMail;
import "package:googleapis_auth/auth_io.dart";
import 'package:flutter/services.dart' show rootBundle;
class Example {
ServiceAccountCredentials credentials;
Future<gMail.GmailApi> getGMailApi() async {
return gMail.GmailApi(await getGoogleClient());
}
Future<AuthClient> getGoogleClient() async {
return await clientViaServiceAccount(await getCredentials(), [
'https://www.googleapis.com/auth/drive',
'https://mail.google.com/',
]);
}
Future<ServiceAccountCredentials> getCredentials() async {
if (credentials == null) {
credentials = ServiceAccountCredentials.fromJson(
json.decode(await rootBundle.loadString('GSuiteServiceAccountInfo.json')));
}
return credentials;
}
String getBase64Email({String source}) {
List<int> bytes = utf8.encode(source);
String base64String = base64UrlEncode(bytes);
return base64StringFormatted;
}
sendEmail({
String from: 'me',
String to: '[email protected]',
String subject: 'Some subject',
String contentType: 'text/html',
String charset: 'utf-8',
String contentTransferEncoding: 'base64',
String emailContent: '<table></table>',
}) async {
(await getGMailApi()).users.messages.send(
gMail.Message.fromJson({
'raw': getBase64Email(
source: 'From: $from\r\n'
'To: $to\r\n'
'Subject: $subject\r\n'
'Content-Type: $contentType; charset=$charset\r\n'
'Content-Transfer-Encoding: $contentTransferEncoding\r\n\r\n'
'$emailContent'), // emailContent is HTML table.
}),
from);
}
}
When I call sendEmail
function I get DetailedApiRequestError(status: 400, message: Bad Request)
. But when I try to send the base64UrlEncoded string through the playground it works, the email is sent.
Here is my flutter doctor -v
:
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.17763.316], locale en-US)
• Flutter version 1.2.1 at C:\src\flutter-0.7.3\flutter
• Framework revision 8661d8aecd (3 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\bbozhidarov\AppData\Local\Android\Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = C:\Users\bbozhidarov\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[√] Android Studio (version 3.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 33.3.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[!] IntelliJ IDEA Community Edition (version 2018.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.1.6
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.io/intellij-setup/#installing-the-plugins
[!] VS Code, 64-bit edition (version 1.30.2)
• VS Code at C:\Program Files\Microsoft VS Code
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)
! Doctor found issues in 2 categories.
And this is my pubspec.yaml
:
name: App Mobile
description: App Mobile
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
intl: 0.15.7
cupertino_icons: 0.1.2
http: 0.11.3+17
shared_preferences: ^0.4.2
google_api_availability: 1.0.4
geolocator: 2.1.0
file_picker: 0.1.6
url_launcher: 4.0.3
flutter_calendar_carousel: 1.3.10
date_util: 0.1.4
permission_handler: 2.1.0
simple_permissions: 0.1.9
logging: 0.11.3+2
googleapis: 0.52.0+1
uuid: 2.0.0
googleapis_auth: 0.2.7
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/email_templates/dynamic_form_email_template.html
- assets/email_templates/dynamic_form_email_data_row_template.html
- GSuiteServiceAccountInfo.json
I exclude the possibility of an issue with the credentials. The same credentials/account/client is working well with DriveApi. Any help will be much appreciated. Thanks.
Hello,
i'm having the following error when calling:
files.list
E/flutter ( 2708): type 'List<dynamic>' is not a subtype of type 'List<String>' where
E/flutter ( 2708): List is from dart:core
E/flutter ( 2708): List is from dart:core
E/flutter ( 2708): String is from dart:core
E/flutter ( 2708):
E/flutter ( 2708): #0 new File.fromJson (package:googleapis/drive/v3.dart:4274:22)
E/flutter ( 2708): #1 new FileList.fromJson.<anonymous closure> (package:googleapis/drive/v3.dart:4546:37)
E/flutter ( 2708): #2 MappedListIterable.elementAt (dart:_internal/iterable.dart:414:29)
E/flutter ( 2708): #3 ListIterable.toList (dart:_internal/iterable.dart:219:19)
E/flutter ( 2708): #4 new FileList.fromJson (package:googleapis/drive/v3.dart:4547:12)
E/flutter ( 2708): #5 FilesResourceApi.list.<anonymous closure> (package:googleapis/drive/v3.dart:1321:41)
E/flutter ( 2708): #6 _RootZone.runUnary (dart:async/zone.dart:1381:54)
E/flutter ( 2708): #7 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
Calling FirestoreApi.listen() always returns 400 Bad Request
.
Unfortunately the documentation doesn't help much here, nor does the error message. From my investigation it seems I'm supplying all of the required parameters, though that's hard to say from just looking at the docs.
The following code shows the issue I'm having. This is on a database with open security rules:
import 'package:googleapis/firestore/v1.dart';
import 'package:http/http.dart' as http;
final projectId = "PROJECT_ID";
final databaseId = "(default)";
final database = "projects/$projectId/databases/$databaseId";
final documentPath = "$database/documents/test_collection/test_document";
final firestore = FirestoreApi(http.Client());
Future main() async {
// Works fine
await getDocument();
// Fails with 400 Bad Request
await listen();
}
Future getDocument() async {
var document = await firestore.projects.databases.documents.get(documentPath);
print(document.fields["test_field"].stringValue);
}
Future listen() async {
var documentsTarget = DocumentsTarget()
..documents = [documentPath];
var target = Target()
..documents = documentsTarget;
var listenRequest = ListenRequest()
..addTarget = target;
var response = await firestore.projects.databases.documents
.listen(listenRequest, database);
}
The outgoing json payload (collected using listenRequest.toJson()
):
{
addTarget: {
documents: {
documents: [
projects/PROJECT_ID/databases/(default)/documents/test_collection/test_document
]
}
}
}
Here's the HTTP response:
<-- 400 Bad Request https://firestore.googleapis.com/v1/projects/PROJECT_ID/databases/(default)/documents:listen?alt=json
[
{
"error": {
"code": 400,
"message": "Invalid value (Object), ",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid value (Object), "
}
]
}
]
}
}
]
Will support for Sheets API API V4 be added ?
<fuchsia>/third_party/dart-pkg/pub/googleapis/lib/admin/directory_v1.dart:11103:19: Error: A value of type '(dart.core::String, dynamic) → dart.core::Null' can't be assigned to a variable of type '(dynamic, dynamic) → void'.
Try changing the type of the left hand side, or casting the right hand side to '(dynamic, dynamic) → void'.
_json.forEach((core.String key, value) {
Issue:
Requests with timeMin or timeMax parameters fail with DetailedApiRequestError(status: 400, message: Bad Request).
Cause:
Because dart DateTime does not handle time zones, the function toIso8601String() does not append a z to the end of the string.
Related Example:
In the the Api explorer, entering a string generated by toIso8601String() will fail
FAILS: 2017-02-03T08:25:15.99878
adding z will work
SUCCESS: 2017-02-03T08:25:15.99878z
Code:
googleapis/calendar/v3.dart
Line 1744:
_queryParams["timeMin"] = [(timeMin).toIso8601String()];
From the documentation
Solution:
We happen to use the clients.dart code (commons.ApiRequester.request)to work with many other API's (Slack, Office 365, our own, ...) and it's very convenient but recently after switching to Dart2 we've discovered that not all of those API's send an integer error code so this line now fails in _validateResponse:
final code = error['code'] as int;
Would you be able to update the code to remove 'as int'?
Office 365 for example sends a String error code.
Thank you.
(Basically a sister issue for dart-archive/discoveryapis_generator#181)
Once dart-archive/discoveryapis_generator#181 is fixed, googleapis need to be regenerated with code that does not use dynamic as bottom, before Dart 2.0 is released. dart-lang/sdk#29630
Running the following code
responses = await (new FirestoreApi(http_client))
.projects
.databases
.documents
.runQuery(
//This should really be a RunQueryRequest, but you get the idea
"{structuredQuery: {from: [{collectionId: messages}], limit: 10, orderBy: [{direction: DESCENDING, field: {fieldPath: createdAt}}]}}",
"projects/REDACTED/databases/(default)/documents/channels/-KyrWc1BnJF2OlXLhRVV",
$fields: "document(fields,name)",
);
Throws an exception:
type 'List' is not a subtype of type 'Map' of '_json@710331970' where
List is from dart:core
Map is from dart:core
The reason is that RunQueryResponse.fromJson
expects a single document (core.Map), while the query above returns a collection (core.List).
I think I am using the query API correctly. Are the API specs incorrect in this case?
I run the example in flutter and i get an error:
import 'package:googleapis/storage/v1.dart';
import 'package:googleapis_auth/auth_io.dart';
final _credentials = new ServiceAccountCredentials.fromJson(r'''
{
"private_key_id": ...,
"private_key": ...,
"client_email": ...,
"client_id": ...,
"type": "service_account"
}
''');
const _SCOPES = const [StorageApi.DevstorageReadOnlyScope];
void main() {
clientViaServiceAccount(_credentials, _SCOPES).then((http_client) {
var storage = new StorageApi(http_client);
storage.buckets.list('dart-on-cloud').then((buckets) {
print("Received ${buckets.items.length} bucket names:");
for (var file in buckets.items) {
print(file.name);
}
});
});
}
E/flutter ( 752): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter ( 752): type '_InternalLinkedHashMap' is not a subtype of type 'Map<String, List>' where
E/flutter ( 752): _InternalLinkedHashMap is from dart:collection
E/flutter ( 752): Map is from dart:core
E/flutter ( 752): String is from dart:core
E/flutter ( 752): List is from dart:core
E/flutter ( 752): String is from dart:core
This is my pubspec.yaml:
name: consumos_app
description: A new Flutter application.
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.0
path_provider: ^0.3.1
json_annotation: ^0.2.2
shared_preferences: "^0.3.3"
intl: "^0.15.2"
googleapis: "^0.50.0"
googleapis_auth: "^0.2.5"
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^0.7.6
json_serializable: ^0.3.2
flutter:
uses-material-design: true
URLs such as http://www.google.com/images/icons/feature/filing_cabinet_search-g16.png
should be https
I opened this in favor of dart-lang/gcloud#45.
packge:flutter hardcodes 0.12.0: https://github.com/flutter/flutter/blob/master/packages/flutter/pubspec.yaml#L39
Please note I'm demonstrating with the Datastore API, but this applies to all API that has double
fields.
Set up a project that uses the Cloud Datastore
Add an entity to the datastore
a. Kind: Foo
b. Key identifier: set it to Custom name
, set the name to bar
c. Add a property
field
Floating point number
d. Click Create
Set up a Dart project that fetches that entity
Run that project in checked mode
The checks pass. Whenever there's a double
field, it should work in checked mode even if the value happens to be an integer.
It fails in checked mode, because for example JSON.decode("0") is int
and JSON.decode("0") is! double
are both true.
In this example in the Value
class in the Datastore, there's a line:
if (_json.containsKey("doubleValue")) {
doubleValue = _json["doubleValue"];
}
If that doubleValue
field happens to contain an integer, like {"doubleValue":7}
, it will be an int
and it will fail in checked mode, the assignment should look something like doubleValue = _json["doubleValue"]?.toDouble()
These sources seems to be generated by a more advanced version of https://github.com/google/apis-client-generator/ and that project seems to be pretty much abandoned, so I'm filing here, because this one seems more active (and also, because it's obvious this project uses a modified or more advanced version of that generator).
The fix looks like something like this on https://github.com/google/apis-client-generator/blob/master/src/googleapis/codegen/languages/dart/0.2/templates/_model_content.tmpl replacing the fromJson
constructor generator:
/** Create new {{ model.className }} from JSON data. */
{{ model.className }}.fromJson(core.Map json) {
{% for property in model.properties %}
if (json.containsKey({% literal property.wireName %})) {
{% if property.data_type.arrayOf %}
{{ property.codeName }} = [];
json[{% literal property.wireName %}].forEach((item) {
{% if property.data_type.baseType.builtIn %}
{{ property.codeName }}.add(item);
{% else %}
{% if property.data_type.baseType.code_type == 'core.double' %}
{{ property.codeName }}.add(new {{ property.data_type.baseType.className }}.fromJson(item?.toDouble()));
{% else %}
{{ property.codeName }}.add(new {{ property.data_type.baseType.className }}.fromJson(item));
{% endif %}
{% endif %}
});
{% else %}
{% if property.data_type.builtIn %}
{% if property.data_type.code_type == 'core.double' %}
{{ property.codeName }} = json[{% literal property.wireName %}]?.toDouble();
{% else %}
{{ property.codeName }} = json[{% literal property.wireName %}];
{% endif %}
{% else %}
{{ property.codeName }} = new {{ property.data_type.className }}.fromJson(json[{% literal property.wireName %}]);
{% endif %}
{% endif %}
}
{% endfor %}
}
I am trying to implement batch requests to Google Drive API to speed up analysis of folders structure. As I see it there is no way to perform batch requests using this library is that right?
Every request is performed right away (for examle https://pub.dartlang.org/documentation/googleapis/0.50.1/googleapis.drive.v3/FilesResourceApi/list.html) so there is no way to collect multiple "prepared" requests, join them together and send as one request to https://www.googleapis-com/batch
, right?
I would like to create a flutter app that is capable of syncing to wearos.
My android app currently utilizes com.google.android.gms:play-services-wearable.
Please add play-services-wearable to the dart libraries.
See https://stackoverflow.com/questions/47148937/how-to-set-the-fields-parameter-in-the-google-drive-googleapis-v3-in-dart/47149162#47149162 for more context.
Essentially, the web Try this API
form at https://developers.google.com/drive/v3/reference/files/list is different enough from the Dart implementation that first-time users may get very confused.
Web version for list():
Try It
button, press Show standard parameters
, and note the fields
param.fields
can be set by just typing in a comma separated string of fields, such as starred,createdTime,webContentLink
.Dart v3 version for list():
fields
isn't recognized as a query param; only by digging into the code do you find that it should be $fields
$fields
, i.e. files/starred,files/createdTime,files/webContentLink
. This isn't mentioned in the documentation. When you only pass in starred,createdTime,webContentLink
, the 400 error that returns is confusing - it says DetailedApiRequestError(status: 400, message: Invalid field selection starred)
, yet the web documentation lists starred
as a field. Appending files/
also seems redundant since we're calling the Files resource's list(), not a generic list() call.Update: It turns out that I had been testing using Files.get() on the web API explorer, where you don't have to specify the resource (fields=starred
), but in the Files.list() web API explorer, you do (fields=files/starred
). This is inconsistent and confusing.
After migrating to Dart2, there are "invalid cast" errors being thrown when using the Dart Google API clients to call the server.
It stems from trying to implicitly downcast a generic Map
to a Map<String, List<String>>
on line 66 in clients.dart:
type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, List<String>>' where
_InternalLinkedHashMap is from dart:collection
Map is from dart:core
String is from dart:core
List is from dart:core
String is from dart:core
#0 ApiRequester.request (package:_discoveryapis_commons/src/clients.dart:66)
#1 PeopleConnectionsResourceApi.list (package:googleapis/people/v1.dart:982)
I try to use the Sheet API v4. In checked mode I got this error with googleapis v0.28.0:
type 'int' is not a subtype of type 'double' of 'value' where
int is from dart:core
double is from dart:core
package:googleapis/sheets/v4.dart 2396:15 Color.blue=
package:googleapis/sheets/v4.dart 2409:7 Color.Color.fromJson
package:googleapis/sheets/v4.dart 2053:29 CellFormat.CellFormat.fromJson
package:googleapis/sheets/v4.dart 5889:27 SpreadsheetProperties.SpreadsheetProperties.fromJson
package:googleapis/sheets/v4.dart 5813:24 Spreadsheet.Spreadsheet.fromJson
package:googleapis/sheets/v4.dart 218:41 SpreadsheetsResourceApi.get.<fn>
with this program
main() async {
var accountCredentials =
new ServiceAccountCredentials.fromJson({
"type": "service_account",
"project_id": "xxx",
"private_key_id": "xxx",
//...
});
var client = await clientViaServiceAccount(
accountCredentials, ['https://www.googleapis.com/auth/spreadsheets']);
var sheetApi = new SheetsApi(client);
await sheetApi.spreadsheets.get('xxx');
client.close();
}
Thanks
There is no complete documentation about access to Realtime Database from standalone Dart application.
Modifying googleapis_examples/drive_upload_download_console, I'm attempting to convert already stored .docx, .xlsx, etc files to their corresponding Google Drive counterpart.
The following code
import 'dart:async';
import 'dart:io';
import 'package:http/http.dart' show Client;
import 'package:googleapis/common/common.dart' show Media, DownloadOptions;
import 'package:googleapis/drive/v2.dart' as drive;
import 'package:path/path.dart' as path;
Future convertFile(drive.DriveApi api,
Client client,
String objectId) {
var completer = new Completer();
api.files.get(objectId).then((drive.File file) {
var fileName = path.basenameWithoutExtension(file.title);
var parents = file.parents;
client.readBytes(file.downloadUrl).then((bytes) {
var driveFile = new drive.File()
..title = fileName
..mimeType = 'application/vnd.google-apps.document'
..parents = parents;
api.files.insert(driveFile)
.then((driveFile){
var byteList = bytes.toList();
var stream = new Stream.fromIterable(byteList);
var media = new Media(stream, byteList.length);
api.files.update(new drive.File(), driveFile.id, uploadMedia: media)
.then((drive.File f){
stream.close().whenComplete((){
api.files.delete(objectId)
.then((_){
completer.complete(true);
print("Converted ${f.id}");
});
});
});
});
});
});
return completer.future;
}
results in the following error.
Unhandled exception:
Uncaught Error: Class 'int' has no instance getter 'length'.
NoSuchMethodError: method not found: 'length'
Receiver: 80
Arguments: []
Stack Trace:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#1 Base64Encoder.bind.onData (package:googleapis/src/common_internal.dart:325:42)
#2 _RootZone.runUnaryGuarded (dart:async/zone.dart:1093)
#3 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341)
#4 _IterablePendingEvents.handleNext (dart:async/stream_impl.dart:549)
#5 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:671)
#6 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#7 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#8 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
#9 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:886)
#1 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#2 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#3 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)
Am I possibly creating the stream and consequently the media instance incorrectly?
I want to use custom search api for my flutter app for android but there are no samples or tutorials for using this please add some samples or tutorials for this
Google Drive API v3 documentation:
Full resources are no longer returned by default. Use the
fields
query parameter to request specific fields to be returned. If left unspecified only a subset of commonly used fields are returned.
Either there is a fields
request (query) parameter in the googleapis Dart library (which I can't find) or the library is useless for Google Drive API v3. Or maybe a workaround?
Stack Overflow: http://stackoverflow.com/q/42600136/1407962
I am working with Youtube API. For Uploading a video we need to convert a file into Inputstream .But iam getting error --| ApiRequestError(message: Invalid response for resumable upload attempt (status was: 500))|--
Kindly help me out to resolve this.
My code is as follows
File postFile = new File(filePath);
Stream<List<int>> inputStream = new File(filePath).openRead();
inputStream
.transform(utf8.decoder)
.listen((String line) {
print('|---$line: ${line.length} bytes ---|');
},
onDone: () { print('File is now closed.'); },
onError: (e) { print('InputStream Error :${e.toString()}'); });
Media uploadMedia = new Media(inputStream,postFile.lengthSync());
Thanks in Advance
Future<DriveApi> getDrive(String sth) async {
final client = await clientViaServiceAccount(credentials, const [DriveApi.DriveScope]);
final drive = DriveApi(client);
return drive;
}
when I call the clientViaServiceAccount, CircularProgressIndicator stuck there but only happens on IOS
device, and the problem is only on physics device, when i test on the simulator device on my mac, no problem. please help
Hello,
When i download a media with the get(fileId)
method i have a problem,
They are all corrupted when i try to read the file i downloaded previously.
I first get the media from google drive,
And them i write the media with writeAsByte on the local system with this code :
drive.Media data = await MainProvider().downloadPlan(event.id);
plansDir.create();
final file = new File('${plansDir.path}/${event.filename}');
data.stream.listen((data) async { // <-- here i write the file and when i read it he is corrupted
await file.writeAsBytes(
data,
mode: FileMode.write,
);
I use an authenthicate OAuth 2.0 client.
It is a big issue beacause i can't download any Media from google drive.
When i list files on google drive it work perfectly so my client is well authenticate.
This is the function that download the Meida from google drive :
drive.Media data = await MainProvider.driveApi.files
.get(id, downloadOptions: drive.DownloadOptions.FullMedia);
return data;
Thank you,
Michel M
I'm using:
Flutter : 1.5.4-hotfix.2
googleapis: ^0.53.0
Can't find a "fields" parameter (for partial response) in the UsersResourceApi methods.
using the StorageApi
client with a package:http
BrowserClient
can result in unsafe headers like "user-agent" and "content-length" getting set. XHRs aren't allowed to set these headers (ref)
Steps to reproduce:
pub global activate webdev && webdev serve
http://localhost:8080
When doing a clientViaUserConsent
I get the following assertion error:
When running without assertions, the code seems to work.
Unhandled exception:
'package:googleapis_auth/src/auth_http_utils.dart': Failed assertion: line 81 pos 12: 'credentials.refreshToken != null': is not true.
#0 _AssertionError._doThrowNew (dart:core-patch/dart:core/errors_patch.dart:37)
#1 _AssertionError._throwNew (dart:core-patch/dart:core/errors_patch.dart:33)
#2 new AutoRefreshingClient (package:googleapis_auth/src/auth_http_utils.dart:81:12)
#3 clientViaUserConsent.<anonymous closure> (package:googleapis_auth/auth_io.dart:53:32)
#4 _RootZone.runUnary (dart:async/zone.dart:1381)
#5 _FutureListener.handleValue (dart:async/future_impl.dart:129)
#6 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633)
#7 _Future._propagateToListeners (dart:async/future_impl.dart:662)
#8 _Future._complete (dart:async/future_impl.dart:467)
#9 _SyncCompleter.complete (dart:async/future_impl.dart:51)
#10 _completeOnAsyncReturn (dart:async-patch/dart:async/async_patch.dart:255)
#11 AuthorizationCodeGrantServerFlow.run (package:googleapis_auth/src/oauth2_flows/auth_code.dart:223:9)
#12 _RootZone.runUnary (dart:async/zone.dart:1381)
#13 _FutureListener.handleValue (dart:async/future_impl.dart:129)
#14 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633)
#15 _Future._propagateToListeners (dart:async/future_impl.dart:662)
#16 _Future._addListener.<anonymous closure> (dart:async/future_impl.dart:342)
#17 _microtaskLoop (dart:async/schedule_microtask.dart:41)
#18 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#19 _Timer._runTimers (dart:isolate-patch/dart:isolate/timer_impl.dart:376)
#20 _Timer._handleMessage (dart:isolate-patch/dart:isolate/timer_impl.dart:401)
#21 _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:163)
main() {
clientViaUserConsent(new ClientId(_CLIENT_ID, _CLIENT_SECRET), _SCOPES, (String str) {
print("asking for consent: $str");
}).then((client) {
});
I want to use the Gmail API to make an email listener in Dart, but there doesn't seem to be any documentation at all for the Dart-specific API.
Can you please provide some documentation? If there already is some, can you provide a link to where the documentation may be?
Hi,
I followed the steps but I still having error.
I got DetailedApiRequestError(status: 404, message: Not Found) when tried to use auth.clientViaServiceAccount(credentials, scopes);
If I use auth.clientViaUserConsent(id, scopes, prompt); (need a browser) works 100% fine
print(client.credentials.accessToken.data); // token OK on both methods
print(client.credentials.idToken); // null on both methods
print(client.credentials.refreshToken); // null when ServiceAccount //OK when UserConsent
The cloud speech API supports streaming recognition via gRPC, but the dart cloud-speech package doesn't support streaming recognition, is there any planned support for this?
Please help me to write request/response from flutter to dialalog.my below code giving error. 404.
Please help me to run these code or any modification need please help me on this.
[+1949 ms] E/flutter (10462): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
[ ] E/flutter (10462): DetailedApiRequestError(status: 404, message: No error details. HTTP status was: 404.)
final scopes = ['https://www.googleapis.com/auth/cloud-platform'];
final authenticatedHttpClient = await clientViaServiceAccount(accountCredentials, scopes);
final df = new DialogflowApi(authenticatedHttpClient);
final session ='https://dialogflow.googleapis.com/v2/projects/chatbot-d5783/agent';
//final session = 'https://dialogflow.googleapis.com/v2/projects/chatbot-d5783/agent/sessions/' + sessionid + ':detectIntent';
print(session);
// Build the request
final inputText = new GoogleCloudDialogflowV2beta1TextInput()
..text = 'Hi'
..languageCode = 'en';
final queryInput = new GoogleCloudDialogflowV2beta1QueryInput()
..text = inputText;
final request = new GoogleCloudDialogflowV2beta1DetectIntentRequest()
..queryInput = queryInput;
// Perform the RPC to dialogflow.
final response = await df.projects.agent.sessions.detectIntent(request, session);
// Use the response.
print(response.queryResult.fulfillmentText);
await authenticatedHttpClient.close();
BR//
Mukut
The delete method does not take a transaction ID, so there appears to be no way to delete a document within the context of a transaction.
Is it possible to upload files from the WEB through googleapis DriveApi instance?
How to convert File() (dart instance) to media file which create method need?
I tried to read the file with FileReader() as readAsArrayBuffer or readAsDataUrl but in first case I'm receiving Uint8List, in second String (base64).
Part of my code:
final reader = new FileReader();
reader.readAsDataUrl(file);
reader.onLoad.listen((e) async{
drive.File fileMetadata = drive.File.fromJson({
"mimeType": file.type,
"name": file.name,
"parents": [folderId]
});
drive.Media fileMedia = drive.Media(reader.result, file.size, contentType: file.type);
drive.DriveApi.files.create(fileMetadata, uploadMedia: fileMedia)
Issue here is that Media() want first parameter to be async.Stream<core.List<core.int>>
;
Can someone give me a solution of creating a file from web with that google package?
pub dependencies: googleapis: ^0.52.0+1
For some reason, the Translate API is not generated correctly, I think.
In translate/v2.dart#L590 it just checks for the existance of the "translations"
key, while the Map
actually has a toplevel "data"
key.
Map object fed into the fromJson
method:
{data: {translations: [{translatedText: Hello, detectedSourceLanguage: de}]}}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.