I am already using a number of Google API services, such as Calendar and Google+ profiles, but using the Directory services is proving difficult.
Here is the scope I'm declaring in my local_config - everything has been working until I added the final line...
// Definition of service specific values like scopes, oauth token URLs, etc
'services' => array(
'analytics' => array('scope' => 'https://www.googleapis.com/auth/analytics.readonly'),
'calendar' => array(
'scope' => array(
"https://www.googleapis.com/auth/calendar",
"https://www.googleapis.com/auth/calendar.readonly",
)
),
'books' => array('scope' => 'https://www.googleapis.com/auth/books'),
'latitude' => array(
'scope' => array(
'https://www.googleapis.com/auth/latitude.all.best',
'https://www.googleapis.com/auth/latitude.all.city',
)
),
'moderator' => array('scope' => 'https://www.googleapis.com/auth/moderator'),
'oauth2' => array(
'scope' => array(
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
)
),
'plus' => array('scope' => 'https://www.googleapis.com/auth/plus.login'),
'siteVerification' => array('scope' => 'https://www.googleapis.com/auth/siteverification'),
'tasks' => array('scope' => 'https://www.googleapis.com/auth/tasks'),
'urlshortener' => array('scope' => 'https://www.googleapis.com/auth/urlshortener'),
'directory' => array('scope' => 'https://www.googleapis.com/auth/admin')
I have tried a few different combos, but nothing seems to work - here is the error I'm getting...
Some requested scopes were invalid.
{valid=[https://www.googleapis.com/auth/tasks,
https://www.googleapis.com/auth/calendar, https://www.googleapis.com/auth/calendar.readonly, https://www.googleapis.com/auth/userinfo.profile,
https://www.googleapis.com/auth/userinfo.email], invalid=[https://www.googleapis.com/auth/admin]}
I'm trying to pull Group listings at the moment, but I'll need other Admin sdk features later.
Thanks! Let me know if I need to add any more details.
Admin SDK scopes are listed at:
https://developers.google.com/admin-sdk/directory/v1/guides/authorizing
Related
I've seen a couple of posts here on this topic, but I can't manage to authenticate by users in a group. If I point the path to where a user is, authentication is successful. It's like it "cannot read" inside the group. I'm must be missing something.
my configs are:
$GLOBALS['ldapdsn'] = array(
// primary server MS AD Server
// port 636 is ldaps and port 389 is ldap
array(
'url' => '172.25.20.3',
'port' => '389',
'version' => '3',
'referral' => 'false',
'basedn' => 'CN=RedcapUsers,OU=RedCap,OU=Srv,DC=mydomain,DC=com',
'binddn' => 'CN=RedcapLdap,OU=RedCap,OU=Srv,DC=mydomain,DC=com',
'bindpw' => 'mypass',
'attributes' => array('sAMAccountName'),
'userattr' => 'sAMAccountName',
'userfilter' => '(objectClass=user)',
), //
RedcapUsers is the AD group.
Binding works fine.
I'm pretty new in code writing.
Filter the AD group ( See last line of code) and issue is resolved !
'url' => 'Active Directory ip',
'port' => '636',
'version' => '3',
'referral' => 'false',
'basedn' => 'OU=Users,DC=Ali,DC=local', // Must be exact OU where users are
'binddn' => 'CN=service_redcap,OU=Users,DC=Ali,DC=local', //-- User who give access to AD
'bindpw' => 'myPassword', // ---Password to above user
'attributes' => array('samAccountName'),
'userattr' => 'samAccountName',
'userfilter' => '(memberOf=CN=REDCAP_GROUP,DC=Ali,DC=local)' //-- Users in this group will loging to Redcap
I am running the following code (I've hidden ID's) to add/update a subscriber's interest groups in a MailChimp list:
$mailchimp->patch('lists/1234567/members/' . md5('test#test.com'), [
'status' => 'subscribed',
'merge_fields' => array(
'FNAME' => 'Ben',
'LNAME' => 'Sinclair',
),
'interests' => array(
'abcd1234' => true,
'defg6789' => true,
),
]);
The interests key is what I'm having issues with.
I presumed whatever you put in this key will overwrite what currently exists.
It doesn't seem to be the case. It only adds new interests but does not remove any if the ID's are not in the array. I am not getting any errors.
Does anyone know how to overwrite interest groups? Or if that's not possible, is there a way to remove interest groups?
For completion I wanted to add this answer so people stumbling upon this post can find a quick solution.
$mailchimp->patch('lists/1234567/members/' . md5('test#test.com'), [
'status' => 'subscribed',
'merge_fields' => array(
'FNAME' => 'Ben',
'LNAME' => 'Sinclair',
),
'interests' => array(
'abcd1234' => true, // Attached
'defg6789' => false, // Detached
)
]);
In this example the interest 'abcd1234' will be attached and the interest 'defg6789' will be detached.
Other interests that are not listed will remain on their original value.
Actually, I'm using "standard" sessions manager config:
http://framework.zend.com/manual/current/en/modules/zend.session.manager.html
I want to use cache and save my session's data into server's cache (memcached) for improves performances and scalability.
I set php.ini like this (localhost memcached):
session.save_handler=memcached
session.save_path= "tcp://127.0.0.1"
and it show this error:
Warning: session_start(): Cannot find save handler 'memcached' - session startup failed in C:\Program Files (x86)\xampp\htdocs\Zend-application\vendor\zendframework\zendframework\library\Zend\Session\SessionManager.php on line 98
So, I don't understand how to configure my config/autoload/global.php and module/application/module.php. it's my first time that I want to implement memcached and caching in general. thanks, so much!
I tried to modify module/application/module.php like this:
---add session and cache ---
use Zend\Session\Config\SessionConfig;
use Zend\Session\Container;
use Zend\Cache\StorageFactory;
use Zend\Session\SaveHandler\Cache;
use Zend\Session\SessionManager;
use Zend\Session\Validator\HttpUserAgent;
use Zend\Session\Validator\RemoteAddr;
--- end session and cache ---
public function onBootstrap($e)
{
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
$this->initSession(array(
'remember_me_seconds' => 180,
'use_cookies' => true,
'cookie_httponly' => true,
'validators' => array(
'Zend\Session\Validator\RemoteAddr',
'Zend\Session\Validator\HttpUserAgent',
'phpSaveHandler' => 'memcached',
'savePath' => 'tcp://127.0.0.1',
)
));
}
public function initSession($config)
{
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions($config);
$sessionManager = new SessionManager($sessionConfig);
$sessionManager->getValidatorChain()
->attach(
'session.validate',
array(new HttpUserAgent(), 'isValid')
)
->attach(
'session.validate',
array(new RemoteAddr(), 'isValid')
);
$cache = StorageFactory::factory(array(
'adapter' => array(
'name' => 'memcached',
'options' => array(
'server' => '127.0.0.1',
),
)
));
$saveHandler = new Cache($cache);
$sessionManager->setSaveHandler($saveHandler);
$sessionManager->start();
Container::setDefaultManager($sessionManager);
}
but it shows this error:
Warning: ini_set() expects parameter 2 to be string, array given in C:\Program Files (x86)\xampp\htdocs\Zend-application\vendor\zendframework\zendframework\library\Zend\Session\Config\SessionConfig.php on line 88
Fatal error: Call to undefined method Zend\Stdlib\CallbackHandler::attach() in C:\Program Files (x86)\xampp\htdocs\Zend-application\module\Application\Module.php on line 68
this is my config/autoload/global.php
return array(
'db' => array(
'driver' => 'Pdo_Mysql',
'charset' => 'utf-8',
'dsn' => 'mysql:dbname=mydb;host=localhost',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
),
),
'session' => array(
'config' => array(
'class' => 'Zend\Session\Config\SessionConfig',
'options' => array(
'name' => 'zend-application',
),
),
'storage' => 'Zend\Session\Storage\SessionArrayStorage',
'validators' => array(
'Zend\Session\Validator\RemoteAddr',
'Zend\Session\Validator\HttpUserAgent',
),
),
);
Hoping it'll help someone, I resolved my issue. I'm working in Win7 enviroment and memcached doesn't work on it! I changed :
session.save_handler=memcached
session.save_path= "tcp://127.0.0.1"
to
session.save_handler=memcache
session.save_path= "tcp://127.0.0.1:11211"
I restored the "standard" session manager config and memcache works correctly. When I'll transfer the entire site to apache server, I'll change php.ini for using memcached.
http://framework.zend.com/manual/current/en/modules/zend.session.manager.html
Does somebody know how to cache doctrine2 entities in a zf2 project. I cant find a tutorial or website where this is explained. I cant find any information to start with defining a entity filecache.
Somebody of you got working links or examples.
Thanks
You have two options
Use doctrine's native caching, e.g. using memcache (in the memcache block you can use any kind of doctrine supported cache, a full list of cache drivers is available).
Use doctrine's adapter for Zend/Cache/Storage to use another cache that you're using elsewhere; the adapter is described in the DoctrineModule docs.
As an example of version two, I have something like the following configuration in a module (actually spread across various config files, so I can't guarantee that copy-pasting verbatim will work).
'services' => array(
'factories' => array(
// Wraps a ZF2 cache storage in a Doctrine compatible way
'doctrine.cache.zend.static.local' => function ($services) {
return new ZendStorageCache($services->get('cache.static.local'));
},
),
'caches' => array(
// A ZF2 cache, can be configured as you like
'cache.static.local' => array(
'adapter' => 'xcache',
'plugins' => array(
'exception_handler' => array(
'throw_exceptions' => false,
),
'serializer',
),
),
),
'doctrine' => array(
'configuration' => array(
'orm_default' => array(
'metadata_cache' => 'zend.static.local',
'query_cache' => 'zend.static.local',
),
),
),
Note that Doctrine annoyingly automatically prefixes "doctrine.cache." to the name of the cache service that you configure, so while we configure "metadata_cache" to "zend.static.local", the actual cache service must be named "doctrine.cache.zend.static.local". Obviously you can call them what you want, but you'll need to add that prefix to whatever you call them.
To activate file cache you just need to add in your module.config.php
'doctrine' => array(
'configuration' => array(
'orm_default' => array(
'metadata_cache' => 'filesystem',
'query_cache' => 'filesystem',
)
),
)
and it will create cache automatically in data/DoctrineModule/cache folder
here is my full doctrine config for ZF 2.2.4 + Doctrine 2
'doctrine' => array(
'driver' => array(
'application_entities' => array(
'class' =>'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/Modulename/Entity')
),
'orm_default' => array(
'drivers' => array(
'Modulename\Entity' => 'application_entities'
),
)
),
'configuration' => array(
'orm_default' => array(
'metadata_cache' => 'filesystem',
'query_cache' => 'filesystem',
)
),
),
I'm using CodeIgniter Payments to integrate with the Paypal API. I believe I am calling the right methods because I'm getting a response of "Success" but I don't see the transaction in the Sandbox. When I use the sample DoDirectPayment file from Paypal I complete the transaction and I can see it in the sandbox.
Here is my code using CodeIgniter Payments:
//load the payment library
$this->load->spark('codeigniter-payments/0.1.4/');
//configure the parameters for the payment request
$paymentParameters = array(
'cc_type' => 'foo',
'cc_number' => 'foo',
'cc_exp' => 'foo',
'first_name' => 'foo',
'last_name' => 'foo',
'street' => 'foo',
'street2' => 'foo',
'city' => 'foo',
'state' => 'foo',
'country' => 'foo',
'postal_code' => 'foo',
'amt' => 'foo',
'currency_code' => 'USD'
);
//make the call
$paymentResponse = $this->payments->oneoff_payment('paypal_paymentspro', $paymentParameters);
//print the response
print_r($paymentResponse);
Here is the response:
stdClass Object
(
[type] => gateway_response
[status] => Success
[response_code] => 100
[response_message] => The authorization was successful.
[details] => stdClass Object
(
[gateway_response] => stdClass Object
(
[TIMESTAMP] => 2012-05-22T19:18:17Z
[CORRELATIONID] => 7939eeaa6c0c0
[ACK] => Success
[VERSION] => 66.0
[BUILD] => 2929894
[AMT] => 20.89
[CURRENCYCODE] => USD
[AVSCODE] => X
[CVV2MATCH] => M
[TRANSACTIONID] => 4RS01101TL8204042
)
[timestamp] => 2012-05-22T19:18:17Z
[identifier] => 4RS01101TL8204042
)
)
You can just switch into using other Paypal libraries. It might save you time than figuring out this problem. http://codeigniter.com/wiki/PayPal_Lib
I had this problem too.
In my case, I did not set my config driver correctly and it ended up sending all my transactions to Calvin's (Author's) default paypal sandbox account.
Double check to make sure that your API tokens are set correctly with:
$gateway_name = 'paypal_paymentspro';
$params = array(
'identifier' => *Your transaction ID from above*
);
$response = $this->payments->get_transaction_details($gateway_name, $params);
print_r($results);
Also, if you don't want to set the driver and want to do everything from your PHP file, you can always pass in your API tokens like so:
$gateway_name = 'paypal_paymentspro';
$params = array(
'identifier' => *Your transaction ID from above*
);
$config['api_username'] = *Your api username*;
$config['api_password'] = *Your api password*;
$config['api_signature'] = *Your sig*;
$response = $this->payments->get_transaction_details($gateway_name, $params);
print_r($results);