Google_Sheet_Helpers::validate_oauth_tokens()
Callback function for OAuth redirect verification.
Source Source
File: src/integrations/google-sheet/helpers/google-sheet-helpers.php
public function validate_oauth_tokens() { if ( ! empty( $_GET['automator_api_message'] ) && isset( $_REQUEST['tab'] ) && $this->setting_tab == $_REQUEST['tab'] ) { try { if ( ! empty( $_GET['automator_api_message'] ) ) { global $uncanny_automator; $secret = get_transient( 'automator_api_google_authorize_nonce' ); $tokens = Automator_Helpers_Recipe::automator_api_decode_message( $_GET['automator_api_message'], $secret ); if ( ! empty( $tokens['access_token'] ) ) { // On success update_option( '_uncannyowl_google_sheet_settings', $tokens ); delete_option( '_uncannyowl_google_sheet_settings_expired' ); //set the transient set_transient( '_uncannyowl_google_sheet_settings', $tokens['access_token'] . '|' . $tokens['refresh_token'], 60 * 50 ); //Refresh the user info. delete_transient( '_uncannyowl_google_user_info' ); wp_safe_redirect( admin_url( 'edit.php?post_type=uo-recipe&page=uncanny-automator-settings&tab=' . $this->setting_tab . '&connect=1' ) ); die; } else { // On Error wp_safe_redirect( admin_url( 'edit.php?post_type=uo-recipe&page=uncanny-automator-settings&tab=' . $this->setting_tab . '&connect=2' ) ); die; } } } catch ( \Exception $e ) { // On Error wp_safe_redirect( admin_url( 'edit.php?post_type=uo-recipe&page=uncanny-automator-settings&tab=' . $this->setting_tab . '&connect=2' ) ); die; } } }
Expand full source code Collapse full source code View on Github