/** * Checks to see if an ads user is authenticating with OAuth 2 or not. * * @param AdsUser $user the AdsUser to test * @return boolean true if using OAuth 2, false otherwise */ public static function IsUsingOAuth2(AdsUser $user) { // AdsUser doesn't have ClientLogin information on it, only the subclasses // do, so we can only check for absence of OAuth 2 here. return $user->GetOAuth2Info() !== NULL; }
/** * Check if a User needs an Client Login warning raised. * * @param AdsUser $user the AdsUser to test * @return boolean TRUE if an OAuth2 Info message should be raised */ public static function ShouldRaiseClientLoginWarning(AdsUser $user) { // Check that they're not using OAuth2 $credentials = $user->GetOAuth2Info(); return empty($credentials['refresh_token']) && empty($credentials['access_token']) && (empty($credentials['client_id']) || empty($credentials['client_secret'])); }