Hi Minas, 

Did you ever find a solution to this? I'm having the same issue.

On Monday, January 9, 2017 at 2:25:05 PM UTC-6, Minas Gratas wrote:
>
> To make successful API calls, the login used to create the client 
>> credentials must match the login with which you generate the OAuth tokens.
>>
> Actually, I want anyone with their credentials to be able to login to the 
> application. I can access with my own credentials however this application 
> is intended to generate a dashboard for a user who logs in. These users are 
> not necessarily MCC users. Is this doable at all?
>
>
> https://github.com/googleads/googleads-php-lib/wiki/API-access-on-behalf-of-your-clients-(web-flow)
>  
> here it says on behalf on your clients. 
> Some apps asks your permissions to manage your  Adwords account and if I 
> login with a normal (non-MCC) account it reaches my campaigns and ad groups 
> etc. I am having an issue on authentication and authorisation step.
>
> On Monday, 9 January 2017 19:24:54 UTC, Sreelakshmi Sasidharan (AdWords 
> API Team) wrote:
>>
>> Hi Minas, 
>>
>> To make successful API calls, the login used to create the client 
>> credentials must match the login with which you generate the OAuth tokens. 
>>
>> If your question is about how multiple users can access your Adwords 
>> accocunt, please check this 
>> <https://support.google.com/adwords/answer/1704346?hl=en-GB> document 
>> which talks about that in detail. Please note that each of these new users 
>> will have to go thorough the OAuth set up for them to make the API calls. 
>>
>> Thanks,
>> Sreelakshmi, AdWords API Team
>>
>> On Friday, January 6, 2017 at 11:48:20 AM UTC-5, Minas Gratas wrote:
>>>
>>> Hello,
>>>
>>> I am working on a basic application which does reporting for our 
>>> clients. It work for my MCC account but I want my clients to log in with 
>>> their Adwords accounts and see their campaigns, ad groups and keywords.
>>>
>>> Basically, I am having an issue on the first step of OAUTH here.
>>>
>>> use Google\Auth\OAuth2;
>>> require_once 'adwords/api/vendor/autoload.php';
>>> use Google\AdsApi\AdWords\AdWordsServices;
>>> use Google\AdsApi\AdWords\AdWordsSessionBuilder;
>>> use Google\AdsApi\AdWords\v201609\cm\CampaignService;
>>> use Google\AdsApi\AdWords\v201609\cm\OrderBy;
>>> use Google\AdsApi\AdWords\v201609\cm\Paging;
>>> use Google\AdsApi\AdWords\v201609\cm\Selector;
>>> use Google\AdsApi\Common\OAuth2TokenBuilder;
>>>
>>> session_start();
>>>
>>> $oauth2 = new OAuth2([
>>>     'authorizationUri' => 'https://accounts.google.com/o/oauth2/v2/auth',
>>>     'tokenCredentialUri' => 'https://www.googleapis.com/oauth2/v4/token',
>>>     'redirectUri' => 'http://localhost:32492/adoauth/',
>>>     'clientId' => '****',
>>>     'clientSecret' => '*****',
>>>     'scope' => 'https://www.googleapis.com/auth/adwords'
>>> ]);
>>>
>>> if (!isset($_GET['code'])) {
>>>     // Create a 'state' token to prevent request forgery.
>>>     // Store it in the session for later validation.
>>>     $oauth2->setState(sha1(openssl_random_pseudo_bytes(1024)));
>>>     $_SESSION['oauth2state'] = $oauth2->getState();
>>>
>>>     // Redirect the user to the authorization URL.
>>>     $config = [
>>>         // Set to 'offline' if you require offline access.
>>>         'access_type' => 'offline'
>>>     ];
>>>     header('Location: ' . $oauth2->buildFullAuthorizationUri($config));
>>>     exit;
>>> }
>>>  elseif (empty($_GET['state'])
>>>
>>>     || ($_GET['state'] !== $_SESSION['oauth2state'])) {
>>>   unset($_SESSION['oauth2state']);
>>>   exit('Invalid state.');
>>> } else {
>>>     $oauth2->setCode($_GET['code']);
>>>     $authToken = $oauth2->fetchAuthToken();
>>>
>>> $session = (new AdWordsSessionBuilder())
>>>     ->fromFile()
>>>     ->withOAuth2Credential($oauth2)
>>>     ->build();
>>>
>>> $adWordsServices = new AdWordsServices();
>>>
>>> $campaignService = $adWordsServices->get($session, CampaignService::class);
>>> $selector = new Selector();
>>>
>>> $selector->setFields(array('Id', 'Name'));
>>> $selector->setOrdering(array(new OrderBy('Name', 'ASCENDING')));
>>>
>>> $page = $campaignService->get($selector);
>>> if (isset($page->entries)) {
>>>
>>>     foreach ($page->entries as $campaign) {
>>>         $campaigns[] = ['id'=>$campaign->id, 'name'=>$campaign->name, 
>>> 'status'=>$campaign->status];
>>>     }
>>>     return $campaigns;
>>> } else {
>>>     print "No campaigns were found.\n";
>>> }
>>> }
>>>
>>>
>>> So I am giving permissions on consent screen, thenI should get the 
>>> authenticated users data such as campaigns, ad groups. However I am having 
>>> this error;
>>> Fatal error: Uncaught exception 
>>> 'Google\AdsApi\AdWords\v201609\cm\ApiException' with message 
>>> '[AuthorizationError.USER_PERMISSION_DENIED @ ; trigger:'<null>']
>>>
>>> Can someone please help me what I am missing?
>>>
>>> Also I am using two different libraries here, one for oAuth and one for 
>>> Adwords API.
>>>
>>> Thank you
>>>
>>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/412ec1f0-26e4-4447-9844-eb07acdd336f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • Re: Auth... Josh Averbeck
    • Re:... 'Sreelakshmi Sasidharan (AdWords API Team)' via AdWords API Forum
    • Aut... SUBIN P VASU
      • ... 'Peter Oliquino' via AdWords API Forum
    • Re:... oskar . stark
      • ... 'Josh Radcliff (AdWords API Team)' via AdWords API Forum
    • Re:... 'Sreelakshmi Sasidharan (AdWords API Team)' via AdWords API Forum
    • Aut... adwords
      • ... 'Shwetha Vastrad (AdWords API Team)' via AdWords API Forum

Reply via email to