I know this question has been asked for several times here but none of the solution worked for me.
Following are the steps I followed to create a service account:
Logged in to Google Play Console account.
Then navigated to Settings > API Access from the left panel.
Scrolled down to Service Accounts section and clicked on Create Service Account.
Followed the instruction mentioned on dialog opened.
While creating service account on Google API Console selected Service account Permissions as Project > Owner
Created key and downloaded in json format.
Now came back to Google Play Console and clicked on Grant Access to grant permission as Administrator.
Now I am using this service account to validate In App Purchases on server but I am getting this error:
{
"errors": [
{
"domain": "androidpublisher",
"reason": "permissionDenied",
"message": "The current user has insufficient permissions to perform the requested operation."
}
],
"code": 401,
"message": "The current user has insufficient permissions to perform the requested operation."
}
}
I am using this php lib and service account method to verify purchases.
Related
I used an service account to upload files to a shared folder in google drive.
After some time I discovered that files owned by service account consumed the service's account drive storage (my bad) and now I have run out drive space for the service account .
I already delegated domain-wide authority to the service account so new files will be owned by me and use my personal storage quota.
Did this: Delegating domain-wide authority to the service account
and this How to use the API Key for Google Drive API from PHP via the google/apiclient
To avoid errors and confusion in the future I'd like to change the owner of older files. I keep getting this error:
{ "error": {
"code": 400,
"message": "Bad Request. User message: \"You can't change the owner of this item.\"",
"errors": [ {
"message": "Bad Request. User message: \"You can't change the owner of this item.\"",
"domain": "global",
"reason": "invalidSharingRequest"
} ]
}
}
Here's my code using PHP Client
$client = new Google_Client();
$client->setApplicationName('My Name');
$client->setScopes(Google_Service_Drive::DRIVE);
$client->setAuthConfig($my_credentials);
$client->setAccessType('offline');
//$client->setSubject('my_personal_account');
$service = new Google_Service_Drive($client);
$newPermission = new Google_Service_Drive_Permission();
$newPermission->setEmailAddress('my_personal_account');
$newPermission->setType('user');
$newPermission->setRole('owner');
$service->permissions->create(
$fileId,
$newPermission,
array("fields" => "id", "transferOwnership" => true)
);
I've got the same error with or without setSubject in the client. I've tried using
$newPermission->setRole('writer');
$newPermission->setPendingOwner(true);
but it didn't work.
Transfering the file ownership can only be done between accounts from the same domain. The error occurs because the service account and your account don't belong to the same domain.
If you have access to a Shared Drive and are able to add users with add files privileges, add the service account and make it move the files to the Shared Drive.
Related
transfer file ownership in Google Drive API
Unable to transfer ownership of file from service account to google drive user
Other related
Google Drive API ownership of files uploaded from service account
Google Drive API - Transfer ownership from Service Account
I have generated a consumer key and consumer secret. The website has SSL installed. I have also installed plugins required for JSON and REST services. This is how the url looks like:
https://<url>/wp-json/wc/v1/products
If you want to test
Consumer Key: ck_8add1dc9101f8793a731d6b9aeaadd319fbedf37
Consumer secret: cs_18980264faa482536874e4544dfce9c090c7e927
When I am trying to get(GET) the product details using Basic Auth by using POSTMAN, a Chrome plugin, I get a JSON response like:
{
"code": "woocommerce_rest_cannot_view",
"message": "Sorry, you cannot list resources.",
"data": {
"status": 401
}
}
I have both the READ and WRITE permissions corresponding to the Consumer key.
I'm testing this RestApi on PostMan RestClient and i disabled SSL certificate verification on this app settings
The API credentials do not have permissions to read data from woocommerce. Please update the permissions from the woo API settings page and make sure the credentials have Read/Write access or at least Read access.
To show google analytics reports->overview in my admin panel, I use
[Best API to display Google Analytics data in my Admin panel with Codeigniter PHP?
and download from [https://github.com/erebusnz/gapi-google-analytics-php-interface][2]
I follow all the steps
Create a Google Developers project
Create service account for this project, see instructions
Download the .p12 file for this service account, upload to the same folder as gapi.class.php
Enable 'analytics API' on the Google Developers console
In Google Analytics Administration > User Management, give the service account 'Read and Analyse' permissions on the analytics accounts you want to access
and make one file named index.php which code as follow
<?php
require 'example.account.php';
foreach($ga->getResults() as $result)
{
echo $result->getUniquePageviews();
echo $result->getPagePath();
}?>
I made change in gapi.class.php
const account_data_url =
'https://analytics.google.com/analytics/web/#embed/report-
home/a110062270w164329621p165035928/';
const report_data_url =
'https://analytics.google.com/analytics/web/#realtime/rt-
overview/a110062270w164329621p165035928/';
and in example.account.php
$ga = new gapi("eva-277#eva-ceramic.iam.gserviceaccount.com", "key.p12");
but after then it shows error
Fatal error: Uncaught exception 'Exception' with the message 'GAPI:
Failed to authenticate user. Error: "{ "error": "invalid_grant",
"error_description": "Invalid JWT: Token must be a short-lived token
(60 minutes) and in a reasonable timeframe. Check your iat and exp
values and use a clock with the skew to account for clock differences
between systems." } "' in file path....
I try above matter in localhost but in google analytics account show information correctly.
I am currently struggling to get access to the google api when impersonating a user.
I can connect as that user however I am getting an error where I am presented with an error:
"error": {
"errors": [
{
"domain": "global",
"reason": "appNotAuthorizedToFile",
"message": "The user has not granted the app <app id> write access to the file <file id>",
"locationType": "header",
"location": "Authorization"
}
],
}
The recommended resolution is to use google Picker and get the user to allow my app to access this file. However as I am using a service account with domain wide delegation and g-suite enabled I thought this wasn't necessary.
my current php code is:
$client = new Google_Client();
$client->setApplicationName($appName);
$client->setAuthConfig($credentials);
$client->addScope($scopes);
$client->setClientId($key);
$client->useApplicationDefaultCredentials();
$client->setSubject($userTobe);
$client->setAccessType('offline');
I am using putenv to push my service_account.json into my file. I followed the quick start as it suggested. I have enabled all the required scopes in the security console. If I specify getRefreshTokenwithAssertion() i can get an access_token starting with ya29. however this still presents the error above.
I am currently at a loss on where to go from here. Any help would be greatly appreciated.
Which scopes are you using? Please ensure you are setting the drive auth scope in your application: https://www.googleapis.com/auth/drive (Google_service_Drive::DRIVE)
Has the client and scopes been authorized in the admin console?
admin console => security => Advanced settings => manage API client access
I have added permission to a folder in Google Drive through API method. I see the email (foobar#example.com) invitation in the Drive UI as well.
My problem is that when I try to remove the permission using:
$permissionId = $service->permissions->getIdForEmail($email)
$service->permissions->delete($fileId, $permissionId);
I get an error:
"code": 404,
"message": "Permission not found: xxxxxxxxxx"
How can you remove a permission from the invite using Google Drive API?