| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | use WPDataAccess\Utilities\WPDA_Remote_Call; |
| 6 | 6 | use WPDataAccess\WPDA; |
| 7 | 7 | |
| 8 | +// phpcs:disable PluginCheck.CodeAnalysis.Offloading.OffloadedContent | |
| 8 | 9 | class WPDA_Google_Drive extends WPDA_Drive { |
| 9 | 10 | |
| 10 | 11 | const GOOGLE_CLIENT_ID = '400971594152-30c2ro61ohe4jbb2jt09n9q86itnkjvm.apps.googleusercontent.com'; |
| 11 | 12 | const GOOGLE_CLIENT_SECRET = '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'; |
| @@ -22,14 +23,8 @@ | ||
| 22 | 23 | } |
| 23 | 24 | |
| 24 | 25 | public function authorize( $authorization, $enabled = true ) { |
| 25 | 26 | |
| 26 | - // Link to authorization application (does not return a authorization code): | |
| 27 | - // Template | |
| 28 | - // https://accounts.google.com/o/oauth2/v2/auth?client_id=YOUR_CLIENT_ID&redirect_uri=GOOGLE_REDIRECT_URI&response_type=code&scope=https://www.googleapis.com/auth/drive.file%20https://www.googleapis.com/auth/drive.readonly&access_type=offline&prompt=consent | |
| 29 | - // Actual | |
| 30 | - // https://accounts.google.com/o/oauth2/v2/auth?client_id=400971594152-30c2ro61ohe4jbb2jt09n9q86itnkjvm.apps.googleusercontent.com&redirect_uri=http://localhost&response_type=code&scope=https://www.googleapis.com/auth/drive.file%20https://www.googleapis.com/auth/drive.readonly&access_type=offline&prompt=consent | |
| 31 | - | |
| 32 | 27 | // TODO: Get authorization code from reply |
| 33 | 28 | |
| 34 | 29 | $response = WPDA_Remote_Call::post( |
| 35 | 30 | 'https://oauth2.googleapis.com/token', |
| @@ -100,9 +95,9 @@ | ||
| 100 | 95 | public function upload_file( $local_file, $remote_file ) { |
| 101 | 96 | |
| 102 | 97 | if ( ! isset( $this->drive['access_token'] ) ) return false; |
| 103 | 98 | |
| 104 | - $file = fopen( $local_file, 'r' ); | |
| 99 | + $file = fopen( $local_file, 'r' ); // phpcs:ignore | |
| 105 | 100 | $file_size = filesize( $local_file ); |
| 106 | 101 | |
| 107 | 102 | $metadata = array( |
| 108 | 103 | 'name' => $remote_file, |
| @@ -112,9 +107,9 @@ | ||
| 112 | 107 | $boundary = uniqid(); |
| 113 | 108 | $delimiter = '----' . $boundary; |
| 114 | 109 | |
| 115 | 110 | fseek( $file, 0 ); |
| 116 | - $file_content = fread( $file, $file_size ); | |
| 111 | + $file_content = fread( $file, $file_size ); // phpcs:ignore | |
| 117 | 112 | |
| 118 | 113 | $body = |
| 119 | 114 | "--$delimiter\r\n" . |
| 120 | 115 | "Content-Type: application/json; charset=UTF-8\r\n\r\n" . |