Reputation: 11
There are a lot of results on Google for this, but most of them are more than a year old.
I used this library but I have an error when I login:
An Error Was Encountered
Google Analytics Api Library: GData authError AuthorizationInvalid Credentials
my controller code is :
$this->load->library('ga_api');
$this->ga_api->login();
$data['google'] = $this->ga_api
->dimension('adGroup , campaign , adwordsCampaignId , adwordsAdGroupId')
->metric('impressions')
->limit(30)
->get_object();
$this->load->view('includes/template', $data);
Upvotes: 1
Views: 5188
Reputation: 22832
I checked the library and it seems to be using v2 of the Reporting API in Google Analytics. There's a new v3 version of that API.
And for authorization it's using ClientLogin. From the ClientLogin docs:
Important: ClientLogin has been officially deprecated as of April 20, 2012. It will continue to work as per our deprecation policy, but we encourage you to migrate to OAuth 2.0 as soon as possible.
.
Important: If any of your customers are having trouble with ClientLogin, their account may not be compatible with it for a variety of possible reasons. For example, accounts that use 2-step verification, SAML, or Open ID are not compatible with ClientLogin. One workaround is to tell users to generate a single-use password, provided by access codes, which allows them to log in to their account in a web browser and generate a long password that they can type into the password field of any application using ClientLogin. A better solution is to convert your app to use OAuth 2.0, which is compatible with all existing Google accounts.
If you have 2-step verification enabled in your account you should try the access codes workaround, otherwise you should contact library developers and propose that they move away from the deprecated authorization method.
Upvotes: 1
Reputation: 49873
it seems you have authentication problems, so your API should register some auth access to google, the only thing you could forgot, and i found in the library doc is:
// Set new profile id if not the default id within your config document
$this->ga = $this->ga_api->login()->init(array('profile_id' => '182918291281'));
i guess you need an API key or to use a profile_id as in this example
Upvotes: 0