Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All,

I want to connect to google drive to display/download/upload files using username and password through c++ project. I was trying to use curl library to achieve this, but i was not successful in doing this.

Could anyone help/guide me in achieving this?
The main issue is to login to user google drive with username and password.
I think once i am able to do this i can move forward.

Earlier there was a Library named GDrive to do this type of stuff, but now it has been deprecated.


Advance Thanks.
RCJ

What I have tried:

I want to connect to google drive to display/download/upload files using username and password through c++ project. I was trying to use curl library to achieve this, but i was not successful in doing this.
Posted
Updated 27-Mar-20 14:07pm
Comments
Mohibur Rashid 6-Jan-20 3:24am    
https://tanaikech.github.io/2017/02/08/file-upload-and-download-with-file-convert-for-curl-using-drive-api/

try google
Member 10042484 6-Jan-20 4:55am    
The link has only curl commands

1 solution

You should check 2 plages:
1. Google Drive API[^]
2. Libcurl API[^]

You can also learn the basics of communicating with this (and other) API's using REST, so you can choose other wrapper libraries or write your own.

Many things has changed since my article was written[^] , but the principle is the same. You use Google's API to log in.

You first connect to the server:
BOOL Connect(LPCTSTR szServerName, INTERNET_PORT nServerPort = INTERNET_DEFAULT_HTTP_PORT);


You "Connect" function should be something like:

BOOL CSmartHTTP::Connect(LPCTSTR serverName, INTERNET_PORT serverPort)
{
  Disconnect();
  if (Initialize())
  {
    m_hConnection = InternetConnect(m_hInet, serverName, serverPort, 
      NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD_PTR) this);
  }
  return (CheckResult(m_hConnection != NULL));
}


Then, without writing the entire code for you, you send request and check the response.

if (SendRequest(res, rs.GetHandle(), header, content, contentLength))
{
  len = sizeof(httpStatus);
  if (!CheckResult(HttpQueryInfo(rs.GetHandle(), HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
    &httpStatus, &len, NULL)))
  {
    res = RES_EWININET;
  }
  else
  {
    result = ReadReplyEx(res, httpStatus, readCallback, userParam, rs.GetHandle());
  }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900