simbor / google-api-adwords-php

Automatically exported from code.google.com/p/google-api-adwords-php
Apache License 2.0
0 stars 0 forks source link

No authorizationUrl provided by UseOAuth2.php example #104

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Which version of the library are you using?
adwords_api_php_4.4.0

Which version of PHP are you using?
5.3.1

What steps will reproduce the problem?
=> Enter $clientId and $clientSecret details into and then run:
php 
\htdocs\php\includes\external\adwords_api_php_4.4.0\examples\AdWords\v201306\Mis
c\UseOAuth2.php

What is the expected output? What do you see instead?
I expect to be given the URL to go to having logged into adwords. This part is 
empty.

Please provide any additional information below.
I've searched the code for "GetOAuth2AuthorizationUrl" and it does't even seem 
to be found?

Please note, this is a follow on from:
https://groups.google.com/forum/embed/?place=forum/adwords-api&showsearch=true&s
howpopout=true&parenturl=https%3A%2F%2Fdevelopers.google.com%2Fadwords%2Fapi%2Fc
ommunity%2F#!topic/adwords-api/LmBu5IxvaQk

Incase anywhere there looks like it needs attention too? But I'm trying this 
apprach now. Thanks.

Original issue reported on code.google.com by earnafi...@gmail.com on 29 Jul 2013 at 2:44

GoogleCodeExporter commented 8 years ago
I had the same issue and by chance I tried the GetRefreshToken.php script and 
realized that it was returning an URL so I decided to change the script with 
what we have in the UseOAuth2.php script and bingo...
So according to my findings you need to set the OAuth2Info with the correct 
details, i.e. client_id and client_secret that you get from the google API 
console, and then get the url from the OAuth2Handler like :

$OAuth2Handler = $user->GetOAuth2Handler();
$authorizationUrl = $OAuth2Handler->GetAuthorizationUrl($user->GetOAuth2Info(), 
NULL, TRUE);

happy coding ;-)

Original comment by jdeara...@auto-planning.fr on 29 Jul 2013 at 4:26

GoogleCodeExporter commented 8 years ago
Thanks! That gets me a step further, but then I get:

OAuth2 authorization successful.
Array
(
    [client_id] => *** removed ***
    [client_secret] => *** removed ***
)
An error has occurred: Validation failed for [refresh_token] with value []: Eith
er the refresh_token or the access_token is required.

So it says it's worked, I have a refresh token, but then when the script tries 
to get the number of campaigns, it's failing.

The details being printed out within $oauth2Info just seem to be the client_id 
and client_secret that I originally provided. So I'm not sure what this script 
adds, ie the URL gives a refresh token, but where does the access_token come 
from?

If anyone could shed any more light on this for me it would be much appreciated!

Original comment by earnafi...@gmail.com on 30 Jul 2013 at 2:16

GoogleCodeExporter commented 8 years ago
The latest major release of the AdWords API client library has many 
improvements for the OAuth2 implementation.

Please update to version 4.5.0 or later and try to run the following example:
https://code.google.com/p/google-api-adwords-php/source/browse/examples/AdWords/
Auth/GetRefreshToken.php

For downloads, navigate to:
https://code.google.com/p/google-api-adwords-php/downloads/list

Regards,

- Paul, AdWords API Team.

Original comment by api.pmat...@gmail.com on 31 Jul 2013 at 4:21

GoogleCodeExporter commented 8 years ago
Thanks Paul, that's cracked it!

Original comment by earnafi...@gmail.com on 31 Jul 2013 at 11:22

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
After running GetRefreshToken.php withthe client_id replaced in the URL, I get:

Your OAuth2 Credentials are incorrect.
Please see the GetRefreshToken.php example.
{
  "error" : "invalid_client"
}

Original comment by ger...@azapi.com on 5 Aug 2013 at 6:02

GoogleCodeExporter commented 8 years ago
This bug has been marked as WontFix. If you're seeing an issue, please open a 
new bug so it can be handled correctly.

When you file a new bug, please include information on which example you're 
running that returns that error. Finally, did you follow the onscreen 
instructions of configuring the refresh_token in your auth.ini?

### Please don't respond to this bug, if your problem still exists create a new 
bug ###

Regards,

- Paul, AdWords API Team.

Original comment by api.pmat...@gmail.com on 6 Aug 2013 at 11:37