Hi I have an problem, so write Forum
xxx.xxx.xxx.xxx:9090/examples/AdWords/v201609/BasicOperations/GetCampaigns.php
myURL
but resopnse is
An error has occurred: { "error": "invalid_grant", "error_description":
"Bad Request", "error_uri": "" }
I don't know why
My auth.ini file
; Detailed descriptions of these properties can be found at:
; https://developers.google.com/adwords/api/docs/headers
developerToken = "NVwDiYyTErihtp917Qq3Xw"
; Optional. Set a friendly application name identifier.
; userAgent = "mezzo"
; Uncomment clientCustomerId to make requests against a single AdWords
account,
; such as when you run the examples.
; If you don't set it here, you can set the client customer ID dynamically:
; $user = new AdWordsUser();
; $user->SetClientCustomerId(...);
clientCustomerId = "270-176-2937"
[OAUTH2]
; If you do not have a client ID or secret, please create one of type
; "installed application" in the Google API console:
; https://cloud.google.com/console
client_id =
"165362560938-5hl9g5gu8fc3tfvaehh4snmek2e034qu.apps.googleusercontent.com"
client_secret = "ROurZ3VnoqjkTkJcdV4EWGgk"
; If you already have a refresh token, enter it below. Otherwise run
; GetRefreshToken.php.
refresh_token = "4/AO_VhK8kxjvXm3kkkDtpAwDQ7iSRtTkIq1PcLKCIWzA"
; Optionally, uncomment the oAuth2AdditionalScopes line to provide
additional
; OAuth2 scopes. The AdWords API OAuth2 scope is always included. For
; additional OAuth2 scopes, reference the OAuth 2.0 Playground
; (https://developers.google.com/oauthplayground/). In the playground, each
; application has a list of OAuth2 scopes. For example, you would enter
; https://www.googleapis.com/auth/analytics here as a value if you would
like
; to include Google Analytics as an additional scope.
; oAuth2AdditionalScopes = "INSERT_COMMA_SEPARATED_LIST_OF_SCOPES_HERE"
and GetRefreshToken.php
<?php
/**
* This example will print out an OAuth2 refresh token. Please copy the
refresh
* token into your auth.ini file after running.
*
* PHP version 5
*
* Copyright 2013, Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package GoogleApiAdsAdWords
* @subpackage Auth
* @category WebServices
* @copyright 2013, Google Inc. All Rights Reserved.
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
* Version 2.0
*/
require_once dirname(__FILE__) . '/init.php';
/**
* Gets an OAuth2 credential.
* @param string $user the user that contains the client ID and secret
* @return array the user's OAuth 2 credentials
*/
function GetOAuth2Credential($user) {
$redirectUri = null;
$offline = true;
// Get the authorization URL for the OAuth2 token.
// No redirect URL is being used since this is an installed application.
A web
// application would pass in a redirect URL back to the application,
// ensuring it's one that has been configured in the API console.
// Passing true for the second parameter ($offline) will provide us a
refresh
// token which can used be refresh the access token when it expires.
$OAuth2Handler = $user->GetOAuth2Handler();
$authorizationUrl = $OAuth2Handler->GetAuthorizationUrl(
$user->GetOAuth2Info(), $redirectUri, $offline);
// In a web application you would redirect the user to the authorization
URL
// and after approving the token they would be redirected back to the
// redirect URL, with the URL parameter "code" added. For desktop
// or server applications, spawn a browser to the URL and then have the
user
// enter the authorization code that is displayed.
printf("Log in to your AdWords account and open the following
URL:\n%s\n\n",
$authorizationUrl);
print "After approving the token enter the authorization code here: ";
$stdin = fopen('php://stdin', 'r');
$code = trim(fgets($stdin));
fclose($stdin);
print "\n";
// Get the access token using the authorization code. Ensure you use the
same
// redirect URL used when requesting authorization.
$user->SetOAuth2Info(
$OAuth2Handler->GetAccessToken(
$user->GetOAuth2Info(), $code, $redirectUri));
// The access token expires but the refresh token obtained for offline use
// doesn't, and should be stored for later use.
return $user->GetOAuth2Info();
}
try {
// Get the client ID and secret from the auth.ini file. If you do not
have a
// client ID or secret, please create one of type "installed application"
in
// the Google API console: https://code.google.com/apis/console#access
// and set it in the auth.ini file.
$user = new AdWordsUser();
$user->LogAll();
// Get the OAuth2 credential.
$oauth2Info = GetOAuth2Credential($user);
// Enter the refresh token into your auth.ini file.
printf("Your refresh token is: %s\n\n", $oauth2Info['refresh_token']);
printf("In your auth.ini file, edit the refresh_token line to be:\n"
. "refresh_token = \"%s\"\n", $oauth2Info['refresh_token']);
} catch (OAuth2Exception $e) {
ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
ExampleUtils::CheckForOAuth2Errors($e);
} catch (Exception $e) {
printf("An error has occurred: %s\n", $e->getMessage());
}
and
I remove this part
// Don't run the example if the file is being included.
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) {
return;
}
plz help me
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
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/bcbee98d-9f96-4f23-a238-10f05ccd98c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.