YouTube Analytics response 403 for requests for more than one user - youtube-analytics

This is my client setup
$this->_client = new Google_Client();
$this->_client->setClientId( $_config['OAUTH2_CLIENT_ID'] );
$this->_client->setClientSecret( $_config['OAUTH2_CLIENT_SECRET'] );
$this->_client->setScopes( array( 'https://www.googleapis.com/auth/youtube', 'https://www.googleapis.com/auth/yt-analytics.readonly' ) );
$this->_client->setAccessType( 'offline' );
$this->_client->setRedirectUri( filter_var( $_config['OAUTH2_REDIRECT_URI'] ), FILTER_SANITIZE_URL );
$this->_analytics = new YoutubeAnalyticsClient( $this, $this->_client );
I make this for each user signed in the system
$this->_analytics->setChannelId( $_usr_yt_channel_id );
$this->_analytics->setStartDate( $_period[0] );
$this->_analytics->setEndDate( $_period[1] );
I have not getting such response only for first sign in user
2014-06-27 12:39:48 Exception: Error calling GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DUCoZb0E-9pd6O7BPhd-tU2NA&start-date=2014-06-15&end-date=2014-06-25&metrics=views&dimensions=country&filters=video%3D%3DftqqLcm5U1U&sort=-views&quotaUser=UCoZb0E-9pd6O7BPhd-tU2NA: (403) Forbidden
2014-06-27 12:39:51 Exception: Error calling GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DUCoZb0E-9pd6O7BPhd-tU2NA&start-date=2014-06-15&end-date=2014-06-25&metrics=viewerPercentage&dimensions=ageGroup&filters=video%3D%3DftqqLcm5U1U&sort=ageGroup&quotaUser=UCoZb0E-9pd6O7BPhd-tU2NA: (403) Forbidden
Removing "quotaUser" doesn't change anything.

Related

Getting Login Issue for New User with CoSign SOAP API

I have created the new user on the CoSign server. I am getting the following response (User password expired) while logging using the ValidateCredentials method.
Array
(
[Success] =>
[ErrData] => Array
(
[Message] => User password expired.
[Module] => ValidateCredentials
[Code] => -36
[InnerCode] => -1878916637
)
)
Can anybody help?
This error means that the user’s password has expired, and you need to reset it

IBM MFP8 JavaScript Adapter connection timeout

I am working with IBM MFP 8 JavaScript Adapters. As per the blogs or documentation below the request from Cordova Application.
var resourceRequest = new WLResourceRequest(
"adapters/LoginAdapter/validateLogin",
WLResourceRequest.POST
);
resourceRequest.sendFormParameters(params).then(
( response ) => {
resolve( response );
}, ( error ) => {
reject( error );
}
);
My problem here is, if I call the above method I get Connection Timeout. But if I pass the full url as below, it works.
var resourceRequest = new WLResourceRequest(
'http://xxx.xx.xx:9080/mfp/api' + "adapters/LoginAdapter/validateLogin",
WLResourceRequest.POST
);
resourceRequest.sendFormParameters(params).then(
( response ) => {
resolve( response );
}, ( error ) => {
reject( error );
}
);
Can anyone please confirm me if I have to pass the full URL for Adapter connection.
Thanks in advance.
Update :
When I try connecting to Adapters from IBM Mobile Simulator, I get the below error and connection is not established.
ERROR TypeError: Cannot read property 'getItem' of undefined
at __WLDAO.getItem (ibmmfpf-preview.js:8285)
at getItemFromMap (ibmmfpf-preview.js:4363)
at Object.__getCachedScopeByResource (ibmmfpf-preview.js:4410)
at __send (ibmmfpf-preview.js:6776)
at sendRequestAsync (ibmmfpf-preview.js:6660)
at WL.ResourceRequest.sendFormParameters (ibmmfpf-preview.js:6577)
at HomePage.webpackJsonp.191.HomePage.login (home.ts:21)
at Object.eval [as handleEvent] (HomePage.html:18)
at handleEvent (core.es5.js:11914)
at callWithDebugContext (core.es5.js:13206)
bound # ibmmfpf-preview.js:1334
View_HomePage_0 # HomePage.html:18
proxyClass # compiler.es5.js:14091
DebugContext_.logError # core.es5.js:13146
bound # ibmmfpf-preview.js:1334
ErrorHandler.handleError # core.es5.js:1144
IonicErrorHandler.handleError # ionic-error-handler.js:63
(anonymous) # core.es5.js:9410
(anonymous) # platform-browser.es5.js:2687
t.invokeTask # polyfills.js:3
onInvokeTask # core.es5.js:4140
t.invokeTask # polyfills.js:3
r.runTask # polyfills.js:3
invoke # polyfills.js:3
ibmmfpf-preview.js:1334 ERROR CONTEXT

Google API Client Libraries -PHP : Google Game Services occurs error (code : 500) without any message

I'm using Google API Client Libraries - PHP and using Service accounts issuing on Google API Console.
I want to get Leaderboards list but error occurs code 500 without any message.
Enabled Google Play Game Management, Google Play Game Services, Google+ API on API Console.
And, Android application using this Leaderboards proper.
What can I do resolve this problem?
request codes(PHP)
set_include_path(get_include_path().PATH_SEPARATOR.'/path/to/google-api-php-client/src');
require_once realpath(dirname(__FILE__).'/google-api-php-client/src/Google/autoload.php');
$client_email = 'myaccount#developer.gserviceaccount.com';
$private_key = file_get_contents('/path/to/my_key_file.p12');
$scopes = array(
Google_Service_Games::GAMES,
Google_Service_Games::PLUS_LOGIN
);
$client = new Google_Client();
$credentials = new Google_Auth_AssertionCredentials(
$client_email,
$scopes,
$private_key
);
$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion();
}
$service = new Google_Service_Games($client);
$response = $service->leaderboards->listLeaderboards();
echo json_encode($response) . "\n";
error occours
Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling GET https://www.googleapis.com/games/v1/leaderboards: (500) {
"error": {
"code": 500,
"message": null
}
}
Additional, It is works simple query - like Book API, returned proper results without error...
$service = new Google_Service_Books($client);
$optParams = array('filter' => 'free-ebooks');
$results = $service->volumes->listVolumes('Korea', $optParams);
var_dump($results) ;
Let me know your any advice.
Thank you for your help. :)

Google oAuth with service account for Google Coordinate

I use the following code to obtain the access token of Google oAuth2.
There is an issue that if I don't add a line to refresh the token with assertion it would return nothing.
Moreover, this refresh token won't work, because when I use this token to access Google Coordinate it returned the 500 Backend Error.
Please correct me.
<?
// codes for getting access token
require_once ('/libs/google-api/src/Google_Client.php');
define('OAUTH2_CLIENT_ID', "MyClientID.apps.googleusercontent.com");
define('SERVICE_ACCOUNT_NAME', "MyEmail#developer.gserviceaccount.com");
define('KEY_FILE', 'f3dc516e866bb9fd42f58f9675d2ed57502d4093-privatekey.p12');
define('EMAIL', 'myEmail');
$key = file_get_contents(KEY_FILE);
$client = new Google_Client();
$client->setApplicationName("test");
$auth=new Google_AssertionCredentials(
SERVICE_ACCOUNT_NAME,
array('https://www.googleapis.com/auth/coordinate'),
$key
);
$client->setClientId(OAUTH2_CLIENT_ID);
$client->setAssertionCredentials($auth);
if($client->getAuth()->isAccessTokenExpired()){
$client->getAuth()->refreshTokenWithAssertion(); // if I didn't add this line it would return nothing
}
$accessToken=$client->getAccessToken();
?>
<?
// Errors of access to Google Coordinate using refresh token
stdClass Object
(
[error] => stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[domain] => global
[reason] => backendError
[message] => Backend Error
)
)
[code] => 500
[message] => Backend Error
)
)
?>
<?
// The refresh token received
{
"access_token":"ya29.1.AADtN_U0EDt_5lGMWWbBSOJActF4qEmVwiQ6EyPpEzrHy_ZUoyw7HxYmsgo-sXt1qPzcce9r8hmbviCKB-zQZMAqiO9-4gWxepbsc5jR7ceSgRRR07QvIIYgFZFoFjYCdg",
"expires_in":3600,
"created":1394837729
}
?>
Since you're receiving an acfess_token it is very unlikely that the error is in the authorization steps. Moreover, the correct answer for any Google API to an invalid token is to supply HTTP error code 401. So it appears to me as if the error is in your usage of the Coordinate API.

Google Apps API (Calendar v3) returns 404 error

I had been working with the Google API (Calendar v3) for a while without problems until I started to receive error messages a week ago. I can still authorize but any request I make returns a 404 error. I also tried to use another Google Apps account and had the same issue.
// Load the API and make an API call.
function makeApiCall() {
gapi.client.load('calendar', 'v3', function() {
var request = gapi.client.calendar.events.list({
'calendarId': 'primary'
});
request.execute(function(resp) {
console.log (resp);
});
});
}
The console log is:
code: 404
data: Array[1]
error: Object
message: "Not Found"
proto: Object