mirror of https://github.com/vitalif/grive2
Extends support application id and secret support
- persistent id's in config - cmake supports id's during config - priority: default(cmake), config, clipull/294/head
parent
39299096cf
commit
79312b9c53
|
@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 2.8)
|
|||
include(GNUInstallDirs)
|
||||
|
||||
# Grive version. remember to update it for every new release!
|
||||
set( GRIVE_VERSION "0.5.2-dev" )
|
||||
set( GRIVE_VERSION "0.5.2-dev" CACHE STRING "Grive version" )
|
||||
message(WARNING "Version to build: ${GRIVE_VERSION}")
|
||||
|
||||
# common compile options
|
||||
add_definitions( -DVERSION="${GRIVE_VERSION}" )
|
||||
|
@ -12,4 +13,3 @@ add_definitions( -D_FILE_OFFSET_BITS=64 -std=c++0x )
|
|||
add_subdirectory( systemd )
|
||||
add_subdirectory( libgrive )
|
||||
add_subdirectory( grive )
|
||||
|
|
@ -159,6 +159,14 @@ Grive uses cmake to build. Basic install sequence is
|
|||
make -j4
|
||||
sudo make install
|
||||
|
||||
Alternativly you can define your own client_id and client_secret during build
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. "-DAPP_ID:STRING=<client_id>" "-DAPP_SECRET:STRING=<client_secret>"
|
||||
make -j4
|
||||
sudo make install
|
||||
|
||||
## Version History
|
||||
|
||||
### Grive2 v0.5.2-dev
|
||||
|
|
|
@ -20,6 +20,17 @@ target_link_libraries( grive_executable
|
|||
grive
|
||||
)
|
||||
|
||||
set(DEFAULT_APP_ID "615557989097-i93d4d1ojpen0m0dso18ldr6orjkidgf.apps.googleusercontent.com")
|
||||
set(DEFAULT_APP_SECRET "xiM8Apu_WuRRdheNelJcNtOD")
|
||||
set(APP_ID ${DEFAULT_APP_ID} CACHE STRING "Application Id")
|
||||
set(APP_SECRET ${DEFAULT_APP_SECRET} CACHE STRING "Application Secret")
|
||||
|
||||
target_compile_definitions ( grive_executable
|
||||
PRIVATE
|
||||
-DAPP_ID="${APP_ID}"
|
||||
-DAPP_SECRET="${APP_SECRET}"
|
||||
)
|
||||
|
||||
set_target_properties( grive_executable
|
||||
PROPERTIES OUTPUT_NAME grive
|
||||
)
|
||||
|
|
|
@ -46,8 +46,8 @@
|
|||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
const std::string default_id = "615557989097-i93d4d1ojpen0m0dso18ldr6orjkidgf.apps.googleusercontent.com" ;
|
||||
const std::string default_secret = "xiM8Apu_WuRRdheNelJcNtOD" ;
|
||||
const std::string default_id = APP_ID ;
|
||||
const std::string default_secret = APP_SECRET ;
|
||||
|
||||
using namespace gr ;
|
||||
namespace po = boost::program_options;
|
||||
|
@ -113,6 +113,7 @@ int Main( int argc, char **argv )
|
|||
( "auth,a", "Request authorization token" )
|
||||
( "id,i", po::value<std::string>(), "Authentication ID")
|
||||
( "secret,e", po::value<std::string>(), "Authentication secret")
|
||||
( "print-url", "Only print url for request")
|
||||
( "path,p", po::value<std::string>(), "Path to working copy root")
|
||||
( "dir,s", po::value<std::string>(), "Single subdirectory to sync")
|
||||
( "verbose,V", "Verbose mode. Enable more messages than normal.")
|
||||
|
@ -174,23 +175,23 @@ int Main( int argc, char **argv )
|
|||
http->SetProgressReporter( pb.get() );
|
||||
}
|
||||
|
||||
std::string id = default_id;
|
||||
std::string secret = default_secret;
|
||||
|
||||
if( vm.count( "id" ) )
|
||||
{
|
||||
id = vm["id"].as<std::string>();
|
||||
}
|
||||
|
||||
if( vm.count( "secret" ) )
|
||||
{
|
||||
secret = vm["secret"].as<std::string>();
|
||||
}
|
||||
|
||||
if ( vm.count( "auth" ) )
|
||||
{
|
||||
std::string id = vm.count( "id" ) > 0
|
||||
? vm["id"].as<std::string>()
|
||||
: default_id ;
|
||||
std::string secret = vm.count( "secret" ) > 0
|
||||
? vm["secret"].as<std::string>()
|
||||
: default_secret ;
|
||||
|
||||
OAuth2 token( http.get(), id, secret ) ;
|
||||
|
||||
if ( vm.count("print-url") )
|
||||
{
|
||||
std::cout << token.MakeAuthURL() << std::endl ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
std::cout
|
||||
<< "-----------------------\n"
|
||||
<< "Please go to this URL and get an authentication code:\n\n"
|
||||
|
@ -206,14 +207,20 @@ int Main( int argc, char **argv )
|
|||
token.Auth( code ) ;
|
||||
|
||||
// save to config
|
||||
config.Set( "id", Val( id ) ) ;
|
||||
config.Set( "secret", Val( secret ) ) ;
|
||||
config.Set( "refresh_token", Val( token.RefreshToken() ) ) ;
|
||||
config.Save() ;
|
||||
}
|
||||
|
||||
std::string refresh_token ;
|
||||
std::string id ;
|
||||
std::string secret ;
|
||||
try
|
||||
{
|
||||
refresh_token = config.Get("refresh_token").Str() ;
|
||||
id = config.Get("id").Str() ;
|
||||
secret = config.Get("secret").Str() ;
|
||||
}
|
||||
catch ( Exception& e )
|
||||
{
|
||||
|
|
|
@ -38,6 +38,10 @@ const std::string default_root_folder = ".";
|
|||
|
||||
Config::Config( const po::variables_map& vm )
|
||||
{
|
||||
if ( vm.count( "id" ) > 0 )
|
||||
m_cmd.Add( "id", Val( vm["id"].as<std::string>() ) ) ;
|
||||
if ( vm.count( "secret" ) > 0 )
|
||||
m_cmd.Add( "secret", Val( vm["secret"].as<std::string>() ) ) ;
|
||||
m_cmd.Add( "new-rev", Val(vm.count("new-rev") > 0) ) ;
|
||||
m_cmd.Add( "force", Val(vm.count("force") > 0 ) ) ;
|
||||
m_cmd.Add( "path", Val(vm.count("path") > 0
|
||||
|
|
Loading…
Reference in New Issue