set_include_path(get_include_path() . PATH_SEPARATOR . $path); require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php'; /** * Runs the example. */ function HandleTwoFactorAuthorizationErrorExample() { // Create an AdWordsUser using the credentials for a 2-step tester account. $user = new AdWordsUser(NULL, '*****@*****.**', 'testaccount'); try { $authToken = $user->GetAuthToken(); printf("Successfully retrieved auth token for the account '%s': '%s'\n", $user->GetEmail(), $authToken); } catch (AuthTokenException $e) { if (strpos($e->GetError(), 'InvalidSecondFactor') !== FALSE) { // See http://goo.gl/SHgXV for more details. print "The account has 2-step verification enabled, so an " . "application-specific password must be used instead.\n"; } else { print "Invalid email or password.\n"; } } } // Don't run the example if the file is being included. if (__FILE__ != realpath($_SERVER['PHP_SELF'])) { return; } try { // Run the example. HandleTwoFactorAuthorizationErrorExample(); } catch (Exception $e) { printf("An error has occurred: %s\n", $e->getMessage()); }
public function testHandleTwoFactorAuthorizationErrorExample() { HandleTwoFactorAuthorizationErrorExample(); }