* http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ include_once __DIR__ . '/../vendor/autoload.php'; include_once "templates/base.php"; echo pageHeader("Retrieving An Id Token"); /************************************************* * Ensure you've downloaded your oauth credentials ************************************************/ if (!($oauth_credentials = getOAuthCredentialsFile())) { echo missingOAuth2CredentialsWarning(); return; } /************************************************ * NOTICE: * The redirect URI is to the current page, e.g: * http://localhost:8080/idtoken.php ************************************************/ $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $client = new Google_Client(); $client->setAuthConfig($oauth_credentials); $client->setRedirectUri($redirect_uri); $client->setScopes('email'); /************************************************ * If we're logging out we just need to clear our * local access token in this case
* http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ include_once __DIR__ . '/../vendor/autoload.php'; include_once "templates/base.php"; echo pageHeader("File Upload - Uploading a simple file"); /************************************************* * Ensure you've downloaded your oauth credentials ************************************************/ if (!($oauth_credentials = getOAuthCredentialsFile())) { return missingOAuth2CredentialsWarning(); } /************************************************ * The redirect URI is to the current page, e.g: * http://localhost:8080/simple-file-upload.php ************************************************/ $redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $client = new Google_Client(); $client->setAuthConfig($oauth_credentials); $client->setRedirectUri($redirect_uri); $client->addScope("https://www.googleapis.com/auth/drive"); $service = new Google_Service_Drive($client); // add "?logout" to the URL to remove a token from the session if (isset($_REQUEST['logout'])) { unset($_SESSION['upload_token']); }