Hi, I am able to access customer id using your code now i want to send invitation to user for that i am using this code
$managedCustomerService = $user->GetService('ManagedCustomerService', 'v201603'); $customerService = $user->GetService("CustomerService"); $customer = $customerService->get(); $linkOperations =array(); $managecustomerlink = new ManagedCustomerLink(); $managecustomerlink->managerCustomerId = '5301609003'; $managecustomerlink->clientCustomerId=$customer->customerId; $managecustomerlink->linkStatus='PENDING'; $linkOperation = new LinkOperation(); $linkOperation->operator = 'ADD' ; $linkOperation->operand = $managecustomerlink ; $linkOperations = array($linkOperation); // $managedCustomerService->mutateLink($linkOperations); $result = $managedCustomerService->mutateLink( $linkOperations ); But in result i am getting this error [ManagedCustomerServiceError.NOT_AUTHORIZED @ operations[0]] its a very big blockage of my work any one help me . Thanks in advance On Wednesday, October 14, 2015 at 8:53:06 PM UTC+5, etienne....@admobio.com wrote: > > Hi and thank you for your answer. > > My problem was that I did not request to get the customer Id based on the > OAuth credentials. > > Now I have this in my code which allows me to retrieve the customer id: > > > $user = new AdWordsUser(); > > $user->SetOAuth2Info(array( > "client_id" => $clientId, > "client_secret" => $clientSecret, > "access_token" => $access_token, > "refresh_token" => $refresh_token > )); > > $customerService = $user->GetService('CustomerService'); > $cust = $customerService->get(); > $user->setCustomerClientId( $cust->customerId ); > > For now I have everything in hand to move forward. Thank you very much for > your useful information! > > Thank you, > Etienne > > > > > On Wednesday, October 14, 2015 at 9:22:46 AM UTC-4, Josh Radcliff (AdWords > API Team) wrote: >> >> Hi, >> >> Is the issue that: >> >> a. You aren't getting back the OAuth credential from your >> *GetOAuth2Credential* call? >> >> OR >> >> b. You are getting back the OAuth credential, but you're not sure what to >> do next? >> >> If a), then I'd recommend going through the PHP library's OAuth2 guide >> <https://github.com/googleads/googleads-php-lib/wiki/Using-OAuth-2.0>. >> >> If b), then the Making Your First Request guide >> <https://developers.google.com/adwords/api/docs/first-request> has some >> helpful instructions for each client library. Just make sure you click the >> *PHP* tab, and the guide will show you how to configure the library and >> make an API request. >> >> Also, you mentioned that you wanted to get account information based on >> the OAuth credentials. Each user is associated with only *one* AdWords >> account (either a Manager Account >> <https://support.google.com/adwords/answer/6139186> or a regular AdWords >> account), and you can get that account's information by issuing a >> CustomerService.get >> <https://developers.google.com/adwords/api/docs/reference/v201509/CustomerService#get> >> call. >> This will give you back the clientCustomerId >> <https://developers.google.com/adwords/api/docs/guides/basic-concepts#soap_headers> >> (among >> other things) of the account associated with your OAuth credentials. >> >> Hope that helps! >> >> Cheers, >> Josh, AdWords API Team >> >> On Tuesday, October 13, 2015 at 3:14:15 PM UTC-4, etienne...com wrote: >>> >>> Hi Umesh and thank you for your response. >>> >>> looked at the link you sent me and in fact the code I have included in >>> my original publication does just that. The visitor is sent to an access >>> request page to the Google server and the visitor is sent back to my page >>> with an authorization code. >>> >>> I use this snippet of code to request access to the account of the >>> visitor: >>> >>> $ user = new AdWordsUser (); >>> $ user-> LogAll (); >>> $ user-> SetOAuth2Info (array ( >>> "client_id" => $ clientId, >>> "client_secret" => $ clientSecret >>> )); >>> >>> >>> // Generate an authorization callback URL Given the URL >>> authUrl GetOAuth2Credential $ = ($ user, $ callbackUrl); >>> // header ("Location:" $ authUrl.); >>> echo '<a href="'.$authUrl.'"> </a> Start process'; >>> >>> >>> Look at my complete code in the original publication. >>> >>> My code, I think is good because it returns an authorization code. I >>> don't understand what I am doing wrong. >>> >>> I am open to any proposal. >>> >>> Thank you ! >>> >>> On Friday, October 9, 2015 at 4:07:51 PM UTC-4, Umesh Dengale wrote: >>>> >>>> Hello, >>>> >>>> The user has to grant access to their manager account(MCC) to get >>>> access to their AdWords accounts information. Please go through the >>>> OAuth2.0 >>>> for Web Server Applications guide >>>> <https://developers.google.com/identity/protocols/OAuth2WebServer> for >>>> more details. >>>> >>>> Thanks, >>>> Umesh, AdWords API Team. >>>> >>> -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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/8f01609b-cca1-42b8-8625-45988aa05d0b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.