Tuesday, February 9, 2016

Re: [google-cloud-sql-discuss] Problem with authorization(Insufficient Permission), export db from cloud sql to bucket(location on another instance)

Hi)
Thanks very much for answer, I added scope Google_Service_SQLAdmin::CLOUD_PLATFORM, and try auth with server key, which was created in credentials section, and I get json file, then put to my project. With Google_Service_SQLAdmin::CLOUD_PLATFORM now returns
Exception 'Google_Service_Exception' with message '{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notAuthorized",
    "message": "The client is not authorized to make this request."
   }
  ],
  "code": 403,
  "message": "The client is not authorized to make this request."
 }
}
'
in /var/www/octopus/vendor/google/apiclient/src/Google/Http/REST.php:123
$instance = 'instance with gcloud';
$project = 'instance where run code(on google compute), and this instance with storage';

$client = new \Google_Client();
$client->setAuthConfig(Yii::getAlias('path_to_json.json');
$client->addScope(\Google_Service_Storage::DEVSTORAGE_FULL_CONTROL);
$client->addScope(\Google_Service_SQLAdmin::CLOUD_PLATFORM);
$sqlAdmin = new \Google_Service_SQLAdmin($client);
$postBody = new \Google_Service_SQLAdmin_InstancesExportRequest();
$sqlAdmin->instances->export($project, $instance, $postBody);

May be I missed something?
Thanks

On Monday, February 8, 2016 at 6:56:19 PM UTC+2, David Newgas wrote:
Hi, It looks like you have only added the Google_service_Storage::DEVSTORAGE_FULL_CONTROL scope. This is used for Google Cloud Storage. If you want to use Google Cloud SQL export to GCS use the "https://www.googleapis.com/auth/cloud-platform" scope as mentioned here. You can access this scope as Google_Service_SQLAdmin::CLOUD_PLATFORM.

On Mon, Feb 8, 2016 at 12:55 AM, Sergey Gulidov <gulid...@gmail.com> wrote:
I have problem with authorization to google service
I have instance where running php script which trying auth by json config
I turn on next services

BigQuery API
Cloud Debugger API
Debuglet Controller API
Google Cloud Dataflow API
Google Cloud Dataproc API
Google Cloud Deployment Manager API
Google Cloud Deployment Manager V2 API
Google Cloud Logging API
Google Cloud SQL
Google Cloud SQL API
Google Cloud Storage
Google Cloud Storage JSON API
Google Compute Engine
Google Compute Engine Autoscaler API
Google Compute Engine Instance Group Manager API
Google Compute Engine Instance Group Updater API
Google Compute Engine Instance Groups API
Google Container Engine API

I created service key and was generated json file on cloud instance
This json file I used in function 'setAuthConfig'

part of script:

$instance = 'instance name where cloud sql';
        $project = 'octopus-bank-api';

        $client = new \Google_Client();
        //$client->useApplicationDefaultCredentials();

$client->setAuthConfig(path_to_file/file.json');

        $client->addScope(\Google_Service_Storage::DEVSTORAGE_FULL_CONTROL);
        $sqlAdmin = new \Google_Service_SQLAdmin($client);

        $postBody = new \Google_Service_SQLAdmin_InstancesExportRequest();

        $sqlAdmin->instances->export($project, $instance, $postBody);



Exception 'Google_Service_Exception' with message '{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "insufficientPermissions",
    "message": "Insufficient Permission"
   }
  ],
  "code": 403,
  "message": "Insufficient Permission"
 }
}
'

in /var/www/octopus/vendor/google/apiclient/src/Google/Http/REST.php:123

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/644ffcfd-fc61-430e-bdce-8d4242bf888a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/8061b93e-3c51-4467-9119-dcbfa4a30398%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment