Git Product home page Git Product logo

google-api-cpp-client's Introduction

Google API C++ Client

This repository is deprecated as of May 30th 2019. Please do not use this for any new projects.

PLEASE READ: If you have a support contract with Google, and need help with this library - please create an issue in the support console.

The current installation has only been tested on Unix/Linux systems; this release does not support Windows.

Building

Prerequisites:

Build Steps:

./prepare_dependencies.py
mkdir build && cd build
../external_dependencies/install/bin/cmake ..
make

Running the Samples

See src/samples/README.md

Building Clients for Other APIs

To download additional APIs specialized for individual Google Services see: http://google.github.io/google-api-cpp-client/latest/available_service_apis.html and use this precise version of the apis client generator: https://github.com/google/apis-client-generator/tree/dcad06f5ff0fecfcf7a029efefe62a6b6287b025

Here's an example invocation:

$ python apis-client-generator/src/googleapis/codegen/generate_library.py --api_name=drive --api_version=v2 --language=cpp --output_dir=/tmp/generated

It should be possible to build this from existing installed libraries. However, the build scripts are not yet written to find them. For initial support simplicity we download and build all the dependencies in the prepare_dependencies.py script for the time being as a one-time brute force preparation.

Getting Help

If you have problems, questions or suggestions, contact: The Google group at https://groups.google.com/group/google-api-cpp-client

Or you may also ask questions on StackOverflow at: http://stackoverflow.com with the tag google-api-cpp-client

PLEASE READ: If you have a support contract with Google, and need help with this library - please create an issue in the support console.

Status

This SDK is deprecated and archived. We don't accept patches any more.

About the branches

The master branch is where development is done. It usually is compatible with the generated libraries available from from google.developers.com. On occasion it gets aheaad of those. It usually catches up in a few days.

The latest generated libraries for any Google API is available automatically from https://developers.google.com/resources/api-libraries/download/<API>/<VERSION>/cpp

For example, for Drive/v2, you would use https://developers.google.com/resources/api-libraries/download/drive/v2/cpp

google-api-cpp-client's People

Contributors

aiuto avatar eesheesh avatar jimmycasey avatar sungjungk avatar surferjeffatgoogle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-api-cpp-client's Issues

std::cout missing #include <iostream>

src/samples/storage_sample_main.cc does not #include <iostream>… compiler complains about no cout in std.

google-api-cpp-client/src/samples/storage_sample_main.cc: In member function ‘void googleapis::StorageSample::Run()’:
google-api-cpp-client/src/samples/storage_sample_main.cc:133:10: error: ‘cout’ is not a member of ‘std’ 
     std::cout << "Could not list buckets: " << status.error_message()          
          ^~~~`

More samples needed

Samples needed to upload, download, create and delete files. I can't find any API document. It seems to me I'll better call python from my CPP application until more CPP samples are available. I've used Azure storage and they have more samples and API documentation.

Calendar sample program does not work well,

Compile and run the calendar sample program, but it comes with these output like below:

SAMPLE: Getting User Authorization

Welcome to the Google APIs for C++ CalendarSample.
You will need to authorize this program to look at your calendar.
If you would like to save these credentials between runs
(or restore from an earlier run) then enter a Google Email Address.
Otherwise just press return.

Address:
Enter the following URL into a browser:
https://accounts.google.com/o/oauth2/auth?client_id=145956129682-b1pb20fote82gao680jt5r3fa9e71m4u.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar&response_type=code

Enter the browser's response to confirm authorization: 4/9wprvnQF1rACiydJxH0xKBBp9mAT1FdpvYHqHQhumnU
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0722 11:01:33.061663 16563 curl_http_transport.cc:238] Using cacerts from /home/lixin/roots.pem
Authorized

SAMPLE: Showing Initial Calendars
==== ERROR ====
Status: Http(404) Not Found
HTTP Status Code = 404

Not Found

SAMPLE: Adding Calendar
==== ERROR ====
Status: Http(404) Not Found
HTTP Status Code = 404

Not Found

SAMPLE: Showing Updated Calendars
==== ERROR ====
Status: Http(404) Not Found
HTTP Status Code = 404

Not Found

SAMPLE: Add Calendar Event
==== ERROR ====
Status: Http(404) Not Found
HTTP Status Code = 404

Not Found

SAMPLE: Patch Calendar Event
==== ERROR ====
Status: Http(404) Not Found
HTTP Status Code = 404

Not Found

SAMPLE: Update Calendar Event
==== ERROR ====
Status: Http(404) Not Found
HTTP Status Code = 404

Not Found

Adding bulk events using a batch request
Error adding batched event 0
NOT_FOUND: Http(404) Not Found
Not Found
Error adding batched event 1
NOT_FOUND: Http(404) Not Found
Not Found
Error adding batched event 2
NOT_FOUND: Http(404) Not Found
Not Found
Error adding batched event 3
NOT_FOUND: Http(404) Not Found
Not Found
Error adding batched event 4
NOT_FOUND: Http(404) Not Found
Not Found
Error adding batched event 5
NOT_FOUND: Http(404) Not Found
Not Found
Error adding batched event 6
NOT_FOUND: Http(404) Not Found
Not Found
Error adding batched event 7
NOT_FOUND: Http(404) Not Found
Not Found
Error adding batched event 8
NOT_FOUND: Http(404) Not Found
Not Found
Error adding batched event 9
NOT_FOUND: Http(404) Not Found
Not Found
All Events

SAMPLE: Deleting Calendar
==== ERROR ====
Status: Http(404) Not Found
HTTP Status Code = 404

Not Found

SAMPLE: Showing Final Calendars
==== ERROR ====
Status: Http(404) Not Found
HTTP Status Code = 404

Not Found

Done!

Incredible a series of not found, I have not change any part of the program,

Error on 'exp' type handling in ID Token

Problem:
The following errors occurred during the attempt to request ID Token with specifying ‘profile’ or ‘email’ in SCOPES parameter.

terminate called after throwing an instance of 'std::runtime_error'
  what():  Type is not convertible to string

Cause:
When receiving ID Token from Google OAuth Server, ‘exp’ in the token is representing the type of integer. Unfortunately, 'google-api-cpp-client' deals with it as a string type; it causes the above problem. For your information, I attached the format of ID Token received from the server.

{
  "azp": "...”,
  "aud": "...",
  "sub": "...",
  "email": "[email protected]",
  "email_verified": true,
  "at_hash": "...",
  "exp": 1533783763,
  "iss": "accounts.google.com",
  "iat": 1533780163
}

Retry when Status Code 403 Forbidden

https://github.com/google/google-api-cpp-client/blob/master/src/googleapis/client/transport/http_transport.cc#L226

This block only retries 401 (Unauthorized). Can it be updated to retry for 403, as well? Certain APIs fail with 403 upon first call when you attempt to use service authorization vs using oauth2. There is attempt to retry with updated headers. If this block checked for 403 in addition to 401, it would resolve this issue.

Not sure if this is the right line to fix though.

Thanks,
Ateeq

Mac build fails if space in path

prepare_dependencies.py script fails with the following message if there is a space in the current path:

  ---------------------------------------------
  Error when bootstrapping CMake:
  Cannot find appropriate Makefile processor on this system.
  Please specify one using environment variable MAKE.
  ---------------------------------------------
  Log of errors: <log file>"
  ---------------------------------------------

Digging into the log file the relevant error appears. It is due to a space in the current path.

Can't build: struct mg_callbacks callbacks_; isn't defined

Finally after installing a few libraries by hand got compiling the code, but not this, cause this struct is undefined, looks like there is code pending to commit.
Thanks.

In file included from /home/iolalla/gcloud-cpp/src/samples/installed_application.cc:39:0:
/home/iolalla/gcloud-cpp/src/googleapis/client/util/mongoose_webserver.h:166:23: error: field ‘callbacks_’ has inco
mplete type ‘googleapis::client::mg_callbacks’
   struct mg_callbacks callbacks_;
                       ^
/home/iolalla/gcloud-cpp/src/googleapis/client/util/mongoose_webserver.h:166:10: note: forward declaration of ‘stru
ct googleapis::client::mg_callbacks’
   struct mg_callbacks callbacks_;

undefined reference to `googleapis::client::New ....

How can I solve it?

../google-api-cpp-client-master/build/lib/libgoogleapis_http.a(media_uploader.cc.o): In function googleapis::client::MediaUploader::CreateMultipartPayloadReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)': media_uploader.cc:(.text+0x1a15): undefined reference to googleapis::client::NewCompositeReaderListAndContainerDeleter(std::vector<googleapis::client::DataReader*, std::allocatorgoogleapis::client::DataReader* >)'
media_uploader.cc:(.text+0x1a27): undefined reference to googleapis::client::NewManagedCompositeDataReader(std::vector<googleapis::client::DataReader*, std::allocator<googleapis::client::DataReader*> > const&, googleapis::Closure*)' ../google-api-cpp-client-master/build/lib/libgoogleapis_http.a(http_request_batch.cc.o): In function googleapis::client::HttpRequestBatch::PrepareFinalHttpRequest()':
http_request_batch.cc:(.text+0x27ce): undefined reference to googleapis::client::NewCompositeReaderListAndContainerDeleter(std::vector<googleapis::client::DataReader*, std::allocator<googleapis::client::DataReader*> >*)' http_request_batch.cc:(.text+0x27e3): undefined reference to googleapis::client::NewManagedCompositeDataReader(std::vector<googleapis::client::DataReader
, std::allocatorgoogleapis::client::DataReader* > const&, googleapis::Closure*)'
collect2: error: ld returned 1 exit status

They are really missing ?

My source:

#include
#include <gflags/gflags.h>
#include <glog/logging.h>
#include
#include
#include "googleapis/base/macros.h"
#include "googleapis/client/data/data_reader.h"
#include "googleapis/client/service/media_uploader.h"
#include "googleapis/client/service/client_service.h"
#include "googleapis/client/data/data_reader.h"
#include "googleapis/client/transport/http_authorization.h"
#include "googleapis/client/transport/http_request.h"
#include "googleapis/client/transport/http_transport.h"
#include "googleapis/client/transport/curl_http_transport.h"
#include "googleapis/client/auth/file_credential_store.h"
#include "googleapis/client/auth/oauth2_authorization.h"
#include "googleapis/client/data/serializable_json.h"
#include "googleapis/client/util/status.h"
#include "googleapis/client/util/uri_utils.h"
#include "googleapis/strings/strcat.h"
#include "googleapis/strings/stringpiece.h"
#include "../google-api-cpp-client-master/service_apis/analytics/google/analytics_api/analytics_api.h"

using googleapis::client::HttpTransport;
using googleapis::client::HttpTransportLayerConfig;
using googleapis::client::OAuth2Credential;
//using googleapis::client::OAuth2ServiceAccountFlow;
#if HAVE_OPENSSL
using googleapis::client::OpenSslCodecFactory;
#endif
using googleapis::client::StatusInvalidArgument;

using googleapis::client::CredentialStore;
using googleapis::client::FileCredentialStoreFactory;
using googleapis::client::OAuth2AuthorizationFlow;
using googleapis::client::OAuth2Credential;
using googleapis::client::OAuth2RequestOptions;
using googleapis::client::HttpTransportOptions;
//using googleapis::client::HttpTransport;
using googleapis::client::HttpTransportFactory;
using googleapis::client::CurlHttpTransport;
using googleapis::client::CurlHttpTransportFactory;
using googleapis::client::DateTime;
using google_analytics_api::AnalyticsService;
using namespace std;

int main(int argc, char* argv[])
{
google::InitGoogleLogging(argv[0]);
google::ParseCommandLineFlags(&argc, &argv, true);
google::InstallFailureSignalHandler();

const std::string jsonFile("AnalyticsService-d724a72419b7.json");

OAuth2Credential credential_;
std::unique_ptr<AnalyticsService> analytics_;
//std::unique_ptr<OAuth2ServiceAccountFlow> flow_;
std::unique_ptr<OAuth2AuthorizationFlow> flow_;
std::unique_ptr<HttpTransportLayerConfig> config_;
googleapis::util::Status status;
config_.reset(new HttpTransportLayerConfig);
HttpTransportFactory* factory = new CurlHttpTransportFactory(config_.get());
config_->ResetDefaultTransportFactory(factory);

//flow_.reset(new OAuth2ServiceAccountFlow(config_->NewDefaultTransportOrDie()));
flow_.reset(new OAuth2AuthorizationFlow(config_->NewDefaultTransportOrDie()));
std::string json(std::istreambuf_iterator<char>(std::ifstream(jsonFile).rdbuf()),
            std::istreambuf_iterator<char>());

flow_->InitFromJson(json);

// --- NO BUILD ERROR WITH THIS
flow_->set_default_scopes( "https://www.googleapis.com/auth/analytics.readonly" );

// --- GOT ERROR ABOVE
//flow_->set_default_scopes( google_analytics_api::AnalyticsService::SCOPES::ANALYTICS_READONLY );

// --- GOT ERROR ABOVE
analytics_.reset(new AnalyticsService(config_->NewDefaultTransportOrDie()));

// --- GOT ERROR ABOVE
//AnalyticsService* ga = new AnalyticsService(config_->NewDefaultTransportOrDie());

if (!status.ok()) printf("status.ok() : ERROR - Could not initialize application.\n");
else
{
    printf("status.ok() : OK - Application succesfully initialized\n");
    //credential_.set_flow(flow_.get());
}
printf("Done\n");
return 0;

}

Incompatible dependencies when linking

I tried to build this tool following the instructions on the README, and got some errors during the linking phase:

# make
[ 17%] Built target googleapis_internal
[ 32%] Built target googleapis_utils
[ 46%] Built target googleapis_http
[ 47%] Built target googleapis_curl_http
[ 48%] Built target googleapis_json
[ 49%] Built target googleapis_jsoncpp
[ 51%] Built target googleapis_scribes
[ 52%] Built target googleapis_jsonplayback
[ 55%] Built target googleapis_oauth2
[ 56%] Built target googleapis_openssl_codec
[ 81%] Built target google_calendar_api
[ 98%] Built target google_storage_api
[ 99%] Built target calendar_sample
Linking CXX executable ../../bin/storage_sample
/usr/bin/ld: skipping incompatible /home/xxx/google-api-cpp-client/external_dependencies/install/lib/libssl.so when searching for -lssl
/usr/bin/ld: skipping incompatible /home/xxx/google-api-cpp-client/external_dependencies/install/lib/libssl.a when searching for -lssl
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: skipping incompatible /home/xxx/google-api-cpp-client/external_dependencies/install/lib/libcrypto.so when searching for -lcrypto
/usr/bin/ld: skipping incompatible /home/xxx/google-api-cpp-client/external_dependencies/install/lib/libcrypto.a when searching for -lcrypto
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
src/samples/CMakeFiles/storage_sample.dir/build.make:98: recipe for target 'bin/storage_sample' failed
make[2]: *** [bin/storage_sample] Error 1
CMakeFiles/Makefile2:711: recipe for target 'src/samples/CMakeFiles/storage_sample.dir/all' failed
make[1]: *** [src/samples/CMakeFiles/storage_sample.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

The prepare_dependencies.py executed without problems, this is the output from it:

# ./prepare_dependencies.py
   Build packages = True
   Download packages = True
   Installing packages = True
   Downloading files to /home/xxx/google-api-cpp-client/external_dependencies
   Installing packages to /home/xxx/google-api-cpp-client/external_dependencies/install
Initializing....
cmake-3.1.1.tar.gz already exists - skipping download from http://www.cmake.org/files/v3.1/cmake-3.1.1.tar.gz
cmake-3.1.1 already configured
cmake-3.1.1 already built
cmake-3.1.1 already installed
openssl-1.1.0e.tar.gz already exists - skipping download from https://www.openssl.org/source/openssl-1.1.0e.tar.gz
NOTE for Google APIs Client Library for C++ Installer:
  If this fails it might be because we guessed the wrong platform.
  Edit prepare_dependencies.py and notify us.
  See the README in the release for contact information.
openssl-1.1.0e already configured
openssl-1.1.0e already built
openssl-1.1.0e already installed
v0.3.4.tar.gz already exists - skipping download from https://github.com/google/glog/archive/v0.3.4.tar.gz
glog-0.3.4 already configured
glog-0.3.4 already built
glog-0.3.4 already installed
v2.2.0.tar.gz already exists - skipping download from https://github.com/gflags/gflags/archive/v2.2.0.tar.gz
gflags-2.2.0 already configured
gflags-2.2.0 already built
gflags-2.2.0 already installed
curl-7.54.0.tar.gz already exists - skipping download from https://github.com/curl/curl/releases/download/curl-7_54_0/curl-7.54.0.tar.gz
curl-7.54.0 already configured
curl-7.54.0 already built
curl-7.54.0 already installed
release-1.7.0.tar.gz already exists - skipping download from https://github.com/google/googlemock/archive/release-1.7.0.tar.gz
jsoncpp-src-0.5.0.tar.gz already exists - skipping download from http://downloads.sourceforge.net/project/jsoncpp/jsoncpp/0.5.0/jsoncpp-src-0.5.0.tar.gz
jsoncpp-src-0.5.0 already configured
jsoncpp-src-0.5.0 already built
>>>  Installing jsoncpp-src-0.5.0

Finished processing ['cmake', 'openssl', 'glog', 'gflags', 'curl', 'gmock', 'jsoncpp']

And finally my system:

# uname -a
Linux xxx 3.16.0-4-586 #1 Debian 3.16.43-2+deb8u5 (2017-09-19) i686 GNU/Linux

# lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 8.9 (jessie)
Release:	8.9
Codename:	jessie

Why are these dependencies incompatible?

Thanks for the help!

Invalid Json

i have got a Big problem.

david@david-U460-MFLGL:/workspace/copy/google-api-cpp-client/build$ ./bin/calendar_sample ./bin/client_secret.json ./bin/roots.pem
WARNING: Logging before InitGoogleLogging() is written to STDERR
E0504 16:21:25.646176 7076 oauth2_authorization.cc:104] Invalid JSON
Could not initialize application.
Invalid JSON
david@david-U460-MFLGL:
/workspace/copy/google-api-cpp-client/build$

Anyone who Plz help ~

Possibly unintended regression in service_apis

Problem

While compiling the provided sample for the Calendar API, I have noticed many undefined references while linking. They were to unimplemented member functions. For example, Event::get_start() in the current master is declared as:

const EventDateTime get_start() const;

Having looked through its corresponding source, it does not seem to be implemented at all.

Possible reason

There was a commit (7edc848) on Jun 4, 2015 that had a possibly unintended side effect. What it did, in particular, was this:

-  const EventDateTime get_start() const {
-     const Json::Value& storage = Storage("start");
-    return client::JsonValueToCppValueHelper<EventDateTime >(storage);
-  }
+  const EventDateTime get_start() const;

It seems to have reverted the member function mentioned above. And this is done to many other member functions across a large number of classes. This explains the multitude of undefined references from linking.

Furthermore, by reverting to this commit in the directory

google-api-cpp-client/service_apis/calendar/google/calendar_api/

the sample compiled and ran just fine.

Possible fix

Looking at the commits in the google-api-cpp-client/service_apis directory, there are limited number of changes in it. It may be possible to fix this, by undoing the above commit and then reapplying the remaining 5. However, whether this should be done, depends on the originally intended changes made in the commit in question. I cannot tell what those were.

It may also have something to do with the google-apis-code-generator not acting on the right sources, of which I have little information on.

Another problem that comes to mind is whether this affects more APIs than the three included. This came to mind because the lastest source from

https://developers.google.com/resources/api-libraries/download/calendar/v3/cpp

is also affected.

Latest downloaded generated bigquery code is incompatible with latest framework code

I just downloaded the latest generated bigquery client C++ API from here.
After unzipping, I look in the included descriptor.json and I see "timestamp": "2017-11-10 04:05" which makes me believe the code I downloaded was generated this November.

But the downloaded generated code appears to be incompatible with the latest google-api-cpp-client framework code from [this repo ](repo https://github.com/google/google-api-cpp-client) even though the relevent files in this repo appear to have not changed in over two years.

One of the compilation errors I am seeing is that the framework is expecting to invoke a method called get_next_page_token() but the generated code for bigquery does not implement that method. I include the full compiler error below.

Full compiler error below:

In file included from /home/rudominer/cobalt/src/third_party/google-api-cpp-client/service_apis/bigquery/google/bigquery_api/bigquery_service.cc:24:
In file included from /home/rudominer/cobalt/src/third_party/google-api-cpp-client/service_apis/bigquery/./google/bigquery_api/bigquery_service.h:32:
/home/rudominer/cobalt/src/third_party/google-api-cpp-client/src/googleapis/client/service/service_request_pager.h:233:45: error: no member named 'get_next_page_token' in 'google_bigquery_api::GetQueryResultsResponse'
set_next_page_token(page_data_storage_->get_next_page_token());
~~~~~~~~~~~~~~~~~~ ^
/home/rudominer/cobalt/src/third_party/google-api-cpp-client/src/googleapis/client/service/service_request_pager.h:259:12: note: in instantiation of member function 'googleapis::client::ServiceRequestPager<google_bigquery_api::JobsResource_GetQueryResultsMethod, google_bigquery_api::GetQueryResultsResponse>::ExecuteNextPage' requested here
explicit EncapsulatedServiceRequestPager(REQUEST* request)
^
/home/rudominer/cobalt/src/third_party/google-api-cpp-client/service_apis/bigquery/google/bigquery_api/bigquery_service.cc:1236:14: note: in instantiation of member function 'googleapis::client::EncapsulatedServiceRequestPager<google_bigquery_api::JobsResource_GetQueryResultsMethod, google_bigquery_api::GetQueryResultsResponse>::EncapsulatedServiceRequestPager' requested here
return new client::EncapsulatedServiceRequestPager<JobsResource_GetQueryResultsMethod, GetQueryResultsResponse>(new JobsResource_GetQueryResultsMethod(service_, credential, project_id, job_id));
^

Tons of depreciation warnings during compile

During the compile there are several depreciation warnings. Most are related to the jsoncpp library.

The only one I see that is not related to the jsoncpp library is readdir_r in src/googleapis/util/file.cc which was deprecated in 2015... The solution is to use readdir instead as discussed on the readdir man page.

Then in various other files uses the following jsoncpp types should be replaced:

  • Json::Reader replaced by Json::CharReader or Json::CharReaderBuilder
  • Json::FastWriter, Json::StyledStreamWriter, and Json::StyledWriter replaced by Json::StreamWriterBuilder
  • Json::Writer replaced by Json::StreamWriter

And the following jsoncpp methods should be replaced:

  • removeMember is used everywhere and should be replaced by using one of the methods that takes the end of the string since UTF-8 strings can have embedded nulls
  • memberName should be replaced by name() for the same UTF-8 reason above
  • getFormatedErrorMessages is deprecated due to misspelling and should be getFormattedErrorMessages instead

Update to 0.1.2

The most recent generated service APIs specify their language_version is 0.1.2 where as the drive and calendar builds that come with this repo specify 0.1. Which makes sense giving that this is API 0.1.

In short, update to 0.1.2

http_transport_test_fixture.cc error

compile output:

/Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc: In member function 'virtual void googleapis::HttpTransportTestFixture_TestTimeout_Test::TestBody()': /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:523:20: error: cannot bind 'std::basic_ostream<char>' lvalue to 'std::basic_ostream<char>&&' << " status=" << http_response->transport_status() ^ In file included from /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/iostream:39:0, from /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:25: /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/ostream:602:5: error: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = googleapis::util::Status]' operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x) ^ /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc: In function 'void googleapis::GatherAsyncResponse(int, googleapis::base::Mutex*, std::vector<googleapis::client::HttpRequest*>*, int*, googleapis::client::HttpRequest*)': /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:762:45: error: cannot bind 'std::basic_ostream<char>' lvalue to 'std::basic_ostream<char>&&' VLOG(1) << "*** Got Response for i=" << i << " status=" << response->status(); ^ In file included from /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/iostream:39:0, from /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:25: /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/ostream:602:5: error: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = googleapis::util::Status]' operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x) ^ /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc: In function 'void googleapis::VerifyAsyncResponse(int, int, googleapis::client::HttpRequest*)': /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:781:45: error: cannot bind 'std::basic_ostream<char>' lvalue to 'std::basic_ostream<char>&&' VLOG(1) << "*** Got Response for i=" << i << " status=" << response->status(); ^ In file included from /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/iostream:39:0, from /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:25: /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/ostream:602:5: error: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = googleapis::util::Status]' operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x) ^ make[2]: *** [src/googleapis/client/CMakeFiles/googleapis_http_transport_test_fixture.dir/transport/test/http_transport_test_fixture.cc.o] Error 1 make[1]: *** [src/googleapis/client/CMakeFiles/googleapis_http_transport_test_fixture.dir/all] Error 2 make: *** [all] Error 2 Cagdass-MacBook-Pro:build cagdascaglak$ make all >> out.txt /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc: In member function 'virtual void googleapis::HttpTransportTestFixture_TestTimeout_Test::TestBody()': /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:523:20: error: cannot bind 'std::basic_ostream<char>' lvalue to 'std::basic_ostream<char>&&' << " status=" << http_response->transport_status() ^ In file included from /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/iostream:39:0, from /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:25: /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/ostream:602:5: error: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = googleapis::util::Status]' operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x) ^ /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc: In function 'void googleapis::GatherAsyncResponse(int, googleapis::base::Mutex*, std::vector<googleapis::client::HttpRequest*>*, int*, googleapis::client::HttpRequest*)': /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:762:45: error: cannot bind 'std::basic_ostream<char>' lvalue to 'std::basic_ostream<char>&&' VLOG(1) << "*** Got Response for i=" << i << " status=" << response->status(); ^ In file included from /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/iostream:39:0, from /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:25: /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/ostream:602:5: error: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = googleapis::util::Status]' operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x) ^ /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc: In function 'void googleapis::VerifyAsyncResponse(int, int, googleapis::client::HttpRequest*)': /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:781:45: error: cannot bind 'std::basic_ostream<char>' lvalue to 'std::basic_ostream<char>&&' VLOG(1) << "*** Got Response for i=" << i << " status=" << response->status(); ^ In file included from /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/iostream:39:0, from /Users/cagdascaglak/Desktop/libsandbox/google-api-cpp-client/src/googleapis/client/transport/test/http_transport_test_fixture.cc:25: /usr/local/Cellar/gcc48/4.8.4/include/c++/4.8.4/ostream:602:5: error: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = googleapis::util::Status]' operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x) ^ make[2]: *** [src/googleapis/client/CMakeFiles/googleapis_http_transport_test_fixture.dir/transport/test/http_transport_test_fixture.cc.o] Error 1 make[1]: *** [src/googleapis/client/CMakeFiles/googleapis_http_transport_test_fixture.dir/all] Error 2 make: *** [all] Error 2

HAVE_UGO_PERMISSIONS and HAVE_FSTAT64 always fail

The tests for HAVE_UGO_PERMISSIONS and HAVE_FSTAT64 in introspect.cmake always since the check_cxx_source_compiles attempts to link the program as an executable program and since there is no main it fails to fully link.

The solution to this problem is to add int main(void) { } after each of the current code fragments.

Additionally, the test for HAVE_FSTAT64 is incorrect. You must specify the type as struct stat64 and not just stat64 at least on my setup (even in C++).

Resumable uploads using MediaUploader class

Hello,

I am looking to use MediaUpload class for uploading large attachments, upto 15 MB.

From source code I found out below mentioned text in googleapis/client/service/media_uploader.h.h file,

  • TODO(user): The interface does not yet support
  • -- streaming content
  • -- resumable uploads
    *-- auto protocol selection

Is there any plan to include resumable download option in Media Uploader?

Or any other way to upload larger attachments while sending an email?

Thanks,
Harshal

Mismatch between functions that take StringPieces and functions that take strings causes runtime errors.

In 32df00d, I regenerated the calendar API using the code in abandoned google/apis-client-generator#29.

The code in this cpp library takes StringPieces like this:

util::Status ClientServiceRequest::AppendVariable(
    const StringPiece& variable_name, const UriTemplateConfig& config,
    string* target)'

But the generated code attempts and fails to override that function with a function takes strings:

  virtual util::Status AppendVariable(
        const string& variable_name,
        const client::UriTemplateConfig& config,
        string* target);

The result is runtime errors when I try to run calendar_sample:

SAMPLE:  Add Calendar Event
F0516 13:15:06.758896 14427 client_service.cc:257] Either override AppendVariable or PrepareHttpRequest
*** Check failure stack trace: ***
Aborted (core dumped)

First upload to GCS always times out

I am using the Google APIs Client library for C++ in order to upload files to a GCS bucket. In my experience the first attempt at an upload always fails with a timeout.
Subsequent upload attempts succeed. Also if I perform a different operation before the first upload, such as listing the buckets, then that succeeds and the
first upload after that succeeds. I only get the timeout if the first thing I do is an upload.

Here is the error I get:

Call to url=https://www.googleapis.com/upload/storage/v1/b/<MY_BUCKET_NAME_REDACTED>/o?uploadType=media&name=<MY_FILE_NAME_REDACTED> failed with http status 0
E1114 10:34:54.355522 18569 gcs_util.cc:113] Error attempting upload: DEADLINE_EXCEEDED: Request timed out

Does anyone have any insight into this issue? Below is a snippet of my code used to perform the upload:

std::unique_ptr<ObjectsResource_InsertMethod> request(
storage_service_->get_objects().NewInsertMethod(
&oauth_credential_, bucket, nullptr, mime_type.c_str(),
NewUnmanagedInMemoryDataReader(file_contents)));
request->set_name(file_path);

// Execute the request.
Json::Value value;
google_storage_api::Object response(&value);
auto status = request->ExecuteAndParseResponse(&response);

I have attached two curl verbose logging output text files. The first one called
"upload-first-fails.txt" is the output from when I do the upload first and it fails.
The second one called "list-first-succeeds.txt" is the output from when I do a
list operation first and that succeeds.

upload-first-fails.txt
list-first-succeeds.txt

datastore API will not compile

After changing functions to make the API work on 0.1, many compile errors show up about not finding certain types such as Value (assuming google_datastore_api::Value) and others. May not have been generated correctly.

Service Account Support

Does the CPP Client API has provision for Service Accounts?

How do you integrate the Service Account implementation into the framework?

Windows support?

It's hard to write any serious application and not support Windows.
Specifically, I was hoping for a C++ Youtube API, so I can stream videos in my multimedia application.

I can`t build to success fallowing this Error.

I have to Explain the step by step .When i was to build.

133 ./prepare_dependencies.py
134 ls
135 mkdir build
136 cd build/
137 ../external_dependencies/install/bin/cmake ..
138 make
First i have to fallowing this Error.

/home/david/workspace/src/google-api-cpp-client/src/googleapis/client/data/jsoncpp_data.cc: In member function ‘virtual googleapis::util::Status googleapis::client::JsonCppData::LoadFromJsonReader(googleapis::client::DataReader_)’:
/home/david/workspace/src/google-api-cpp-client/src/googleapis/client/data/jsoncpp_data.cc:64:46: error: ‘class Json::Reader’ has no member named ‘getFormattedErrorMessages’
return StatusInvalidArgument(json_reader.getFormattedErrorMessages());
^
make[2]: *_* [src/googleapis/client/CMakeFiles/googleapis_jsoncpp.dir/data/jsoncpp_data.cc.o]
make[1]: *** [src/googleapis/client/CMakeFiles/googleapis_jsoncpp.dir/all] 2
make: *** [all] 2

I was correct the bad word ‘getFormattedErrorMessages- >‘getFormatedErrorMessages
140 ls
141 cd ..
142 ls
143 vi CMakeLists.txt
144 vi /home/david/workspace/src/google-api-cpp-client/src/googleapis/client/data/jsoncpp_data.cc
145 cd build/
146 make
[ 87%] Building CXX object src/samples/CMakeFiles/calendar_sample.dir/calendar_sample_main.cc.o
Linking CXX executable ../../bin/calendar_sample
/usr/bin/ld: cannot find -lgoogle_calendar_api
collect2: error: ld returned 1 exit status
make[2]: *** [bin/calendar_sample] 1
make[1]: *** [src/samples/CMakeFiles/calendar_sample.dir/all] 2
make: *** [all] 2
Second I was Correct the CMakefile in root dir.

OFF -> option(googleapis_build_service_apis "Build specialized service APIs." ON)
OFF -> option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." ON)

and Service_api/Cmakefile.txt
if(${dir} MATCHES "^([^/])//CMakeLists.txt")
-> if(${dir} MATCHES "^([^/]
)/CMakeLists.txt")

CMakeFiles/calendar_sample.dir/calendar_sample_main.cc.o: In function googleapis::Display(std::string const&, google_calendar_api::Event const&)': calendar_sample_main.cc:(.text+0x8ef): undefined reference togoogle_calendar_api::Event::get_start() const'
calendar_sample_main.cc:(.text+0x924): undefined reference to google_calendar_api::Event::get_start() const' calendar_sample_main.cc:(.text+0x9bb): undefined reference togoogle_calendar_api::Event::get_end() const'
calendar_sample_main.cc:(.text+0x9f0): undefined reference to google_calendar_api::Event::get_end() const' CMakeFiles/calendar_sample.dir/calendar_sample_main.cc.o: In functiongoogleapis::CalendarSample::Startup(int, char*)':
calendar_sample_main.cc:(.text+0xd6e): undefined reference to googleapis::client::OAuth2AuthorizationFlow::MakeFlowFromClientSecretsPath(std::string const&, googleapis::client::HttpTransport_, googleapis::util::Status_)' CMakeFiles/calendar_sample.dir/calendar_sample_main.cc.o: In function googleapis::CalendarSample::Run()':
calendar_sample_main.cc:(.text+0x2659): undefined reference togoogle_calendar_api::Event::mutable_start()' calendar_sample_main.cc:(.text+0x26dc): undefined reference to google_calendar_api::Event::mutable_end()'
calendar_sample_main.cc:(.text+0x28ba): undefined reference togoogle_calendar_api::Event::mutable_start()' calendar_sample_main.cc:(.text+0x293d): undefined reference to google_calendar_api::Event::mutable_end()'
calendar_sample_main.cc:(.text+0x2b2f): undefined reference togoogle_calendar_api::Event::mutable_start()' calendar_sample_main.cc:(.text+0x2bc4): undefined reference to google_calendar_api::Event::mutable_end()'
CMakeFiles/calendar_sample.dir/calendar_sample_main.cc.o: In functionvoid googleapis::DisplayList<google_calendar_api::CalendarList, google_calendar_api::CalendarListEntry>(std::string const&, std::string const&, google_calendar_api::CalendarList const&)': calendar_sample_main.cc:(.text._ZN10googleapis11DisplayListIN19google_calendar_api12CalendarListENS1_17CalendarListEntryEEEvRKSsS5_RKT_[_ZN10googleapis11DisplayListIN19google_calendar_api12CalendarListENS1_17CalendarListEntryEEEvRKSsS5_RKT_]+0xda): undefined reference to google_calendar_api::CalendarList::get_items() const'
CMakeFiles/calendar_sample.dir/calendar_sample_main.cc.o: In functionvoid googleapis::DisplayList<google_calendar_api::Events, google_calendar_api::Event>(std::string const&, std::string const&, google_calendar_api::Events const&)': calendar_sample_main.cc:(.text._ZN10googleapis11DisplayListIN19google_calendar_api6EventsENS1_5EventEEEvRKSsS5_RKT_[_ZN10googleapis11DisplayListIN19google_calendar_api6EventsENS1_5EventEEEvRKSsS5_RKT_]+0xda): undefined reference to google_calendar_api::Events::get_items() const'
collect2: error: ld returned 1 exit status
make[2]: *
* [bin/calendar_sample] 1
make[1]: *** [src/samples/CMakeFiles/calendar_sample.dir/all] 2
make: *** [all] 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.