Google Spreadsheet API - Accessing a spreadsheet created with service account
up vote
0
down vote
favorite
I created a service provider in my laravel app which connects with the google spreadsheet API, and I am able to create new spreadsheets, edit existing ones (with the right sharing permissions of course) and so on.
The problem is that I supplied my service account's json credentials key, hence the spreadsheets that are being created are owned by this cryptic mail address, so after the creation - I get an ID and when I'm trying to access the spreadsheet it gives me this 'request access' page, and when i'm trying to request access to my own email (I defined myself as an 'owner' of the project as well), I get these delivery status notifications via mail -
Your message wasn't delivered to
xxxxxx@yyyyyy-1x3x71x4x27x4.iam.gserviceaccount.com because the domain
admanager-1x3x71x4x27x4.iam.gserviceaccount.com couldn't be found.
Check for typos or unnecessary spaces and try again.
Obviously it's trying to send an email from me (xxxx@gmail.com
) to my service account email, to request an access to this specific spreadsheet, and of course this address doesn't really exist. I feel like I'm doing something wrong from the very first place..
GoogleServiceProvider.php -
class GoogleServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->singleton('google_spreadsheet_client', function ($app) {
// we will instantiate the Google Spread Sheet Client once in this function
$client = new Google_Client();
$client->setApplicationName('xxxxx');
$client->setScopes(Google_Service_Sheets::SPREADSHEETS);
$client->setAuthConfig('xxxxxx-1xyxyxyxyxyxy-221ca2fc3123.json');
$google_service_sheets = new Google_Service_Sheets($client);
return $google_service_sheets;
});
}
SpreadsheetController.php
class SpreadsheetsController extends Controller {
public function create() {
$service = resolve('google_spreadsheet_client');
$spreadsheet = new Google_Service_Sheets_Spreadsheet([
'properties' => [
'title' => 'test'
]
]);
$spreadsheet = $service->spreadsheets->create($spreadsheet, [
'fields' => 'spreadsheetId'
]);
printf("Spreadsheet ID: %sn", $spreadsheet->spreadsheetId);
}
}
And as I said - I do get a response with a string that looks like an actual spreadsheet ID, but can't access it with my own email for some reason..
google-sheets google-api google-drive-sdk google-oauth
add a comment |
up vote
0
down vote
favorite
I created a service provider in my laravel app which connects with the google spreadsheet API, and I am able to create new spreadsheets, edit existing ones (with the right sharing permissions of course) and so on.
The problem is that I supplied my service account's json credentials key, hence the spreadsheets that are being created are owned by this cryptic mail address, so after the creation - I get an ID and when I'm trying to access the spreadsheet it gives me this 'request access' page, and when i'm trying to request access to my own email (I defined myself as an 'owner' of the project as well), I get these delivery status notifications via mail -
Your message wasn't delivered to
xxxxxx@yyyyyy-1x3x71x4x27x4.iam.gserviceaccount.com because the domain
admanager-1x3x71x4x27x4.iam.gserviceaccount.com couldn't be found.
Check for typos or unnecessary spaces and try again.
Obviously it's trying to send an email from me (xxxx@gmail.com
) to my service account email, to request an access to this specific spreadsheet, and of course this address doesn't really exist. I feel like I'm doing something wrong from the very first place..
GoogleServiceProvider.php -
class GoogleServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->singleton('google_spreadsheet_client', function ($app) {
// we will instantiate the Google Spread Sheet Client once in this function
$client = new Google_Client();
$client->setApplicationName('xxxxx');
$client->setScopes(Google_Service_Sheets::SPREADSHEETS);
$client->setAuthConfig('xxxxxx-1xyxyxyxyxyxy-221ca2fc3123.json');
$google_service_sheets = new Google_Service_Sheets($client);
return $google_service_sheets;
});
}
SpreadsheetController.php
class SpreadsheetsController extends Controller {
public function create() {
$service = resolve('google_spreadsheet_client');
$spreadsheet = new Google_Service_Sheets_Spreadsheet([
'properties' => [
'title' => 'test'
]
]);
$spreadsheet = $service->spreadsheets->create($spreadsheet, [
'fields' => 'spreadsheetId'
]);
printf("Spreadsheet ID: %sn", $spreadsheet->spreadsheetId);
}
}
And as I said - I do get a response with a string that looks like an actual spreadsheet ID, but can't access it with my own email for some reason..
google-sheets google-api google-drive-sdk google-oauth
has your Service Account created a Permission to your User Account for the new spreadsheet?
– pinoyyid
Nov 11 at 17:25
not sure about it.. can you elaborate please?
– Gonras Karols
Nov 11 at 23:49
I'm guessing you didn't. see developers.google.com/drive/api/v3/reference/permissions
– pinoyyid
Nov 12 at 2:03
@GonrasKarols How are you going with your Google scripts problem? Worked it out, or still needing help?
– Tedinoz
Nov 23 at 21:47
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I created a service provider in my laravel app which connects with the google spreadsheet API, and I am able to create new spreadsheets, edit existing ones (with the right sharing permissions of course) and so on.
The problem is that I supplied my service account's json credentials key, hence the spreadsheets that are being created are owned by this cryptic mail address, so after the creation - I get an ID and when I'm trying to access the spreadsheet it gives me this 'request access' page, and when i'm trying to request access to my own email (I defined myself as an 'owner' of the project as well), I get these delivery status notifications via mail -
Your message wasn't delivered to
xxxxxx@yyyyyy-1x3x71x4x27x4.iam.gserviceaccount.com because the domain
admanager-1x3x71x4x27x4.iam.gserviceaccount.com couldn't be found.
Check for typos or unnecessary spaces and try again.
Obviously it's trying to send an email from me (xxxx@gmail.com
) to my service account email, to request an access to this specific spreadsheet, and of course this address doesn't really exist. I feel like I'm doing something wrong from the very first place..
GoogleServiceProvider.php -
class GoogleServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->singleton('google_spreadsheet_client', function ($app) {
// we will instantiate the Google Spread Sheet Client once in this function
$client = new Google_Client();
$client->setApplicationName('xxxxx');
$client->setScopes(Google_Service_Sheets::SPREADSHEETS);
$client->setAuthConfig('xxxxxx-1xyxyxyxyxyxy-221ca2fc3123.json');
$google_service_sheets = new Google_Service_Sheets($client);
return $google_service_sheets;
});
}
SpreadsheetController.php
class SpreadsheetsController extends Controller {
public function create() {
$service = resolve('google_spreadsheet_client');
$spreadsheet = new Google_Service_Sheets_Spreadsheet([
'properties' => [
'title' => 'test'
]
]);
$spreadsheet = $service->spreadsheets->create($spreadsheet, [
'fields' => 'spreadsheetId'
]);
printf("Spreadsheet ID: %sn", $spreadsheet->spreadsheetId);
}
}
And as I said - I do get a response with a string that looks like an actual spreadsheet ID, but can't access it with my own email for some reason..
google-sheets google-api google-drive-sdk google-oauth
I created a service provider in my laravel app which connects with the google spreadsheet API, and I am able to create new spreadsheets, edit existing ones (with the right sharing permissions of course) and so on.
The problem is that I supplied my service account's json credentials key, hence the spreadsheets that are being created are owned by this cryptic mail address, so after the creation - I get an ID and when I'm trying to access the spreadsheet it gives me this 'request access' page, and when i'm trying to request access to my own email (I defined myself as an 'owner' of the project as well), I get these delivery status notifications via mail -
Your message wasn't delivered to
xxxxxx@yyyyyy-1x3x71x4x27x4.iam.gserviceaccount.com because the domain
admanager-1x3x71x4x27x4.iam.gserviceaccount.com couldn't be found.
Check for typos or unnecessary spaces and try again.
Obviously it's trying to send an email from me (xxxx@gmail.com
) to my service account email, to request an access to this specific spreadsheet, and of course this address doesn't really exist. I feel like I'm doing something wrong from the very first place..
GoogleServiceProvider.php -
class GoogleServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->singleton('google_spreadsheet_client', function ($app) {
// we will instantiate the Google Spread Sheet Client once in this function
$client = new Google_Client();
$client->setApplicationName('xxxxx');
$client->setScopes(Google_Service_Sheets::SPREADSHEETS);
$client->setAuthConfig('xxxxxx-1xyxyxyxyxyxy-221ca2fc3123.json');
$google_service_sheets = new Google_Service_Sheets($client);
return $google_service_sheets;
});
}
SpreadsheetController.php
class SpreadsheetsController extends Controller {
public function create() {
$service = resolve('google_spreadsheet_client');
$spreadsheet = new Google_Service_Sheets_Spreadsheet([
'properties' => [
'title' => 'test'
]
]);
$spreadsheet = $service->spreadsheets->create($spreadsheet, [
'fields' => 'spreadsheetId'
]);
printf("Spreadsheet ID: %sn", $spreadsheet->spreadsheetId);
}
}
And as I said - I do get a response with a string that looks like an actual spreadsheet ID, but can't access it with my own email for some reason..
google-sheets google-api google-drive-sdk google-oauth
google-sheets google-api google-drive-sdk google-oauth
edited Nov 12 at 2:07
pinoyyid
13k73678
13k73678
asked Nov 9 at 11:38
Gonras Karols
229319
229319
has your Service Account created a Permission to your User Account for the new spreadsheet?
– pinoyyid
Nov 11 at 17:25
not sure about it.. can you elaborate please?
– Gonras Karols
Nov 11 at 23:49
I'm guessing you didn't. see developers.google.com/drive/api/v3/reference/permissions
– pinoyyid
Nov 12 at 2:03
@GonrasKarols How are you going with your Google scripts problem? Worked it out, or still needing help?
– Tedinoz
Nov 23 at 21:47
add a comment |
has your Service Account created a Permission to your User Account for the new spreadsheet?
– pinoyyid
Nov 11 at 17:25
not sure about it.. can you elaborate please?
– Gonras Karols
Nov 11 at 23:49
I'm guessing you didn't. see developers.google.com/drive/api/v3/reference/permissions
– pinoyyid
Nov 12 at 2:03
@GonrasKarols How are you going with your Google scripts problem? Worked it out, or still needing help?
– Tedinoz
Nov 23 at 21:47
has your Service Account created a Permission to your User Account for the new spreadsheet?
– pinoyyid
Nov 11 at 17:25
has your Service Account created a Permission to your User Account for the new spreadsheet?
– pinoyyid
Nov 11 at 17:25
not sure about it.. can you elaborate please?
– Gonras Karols
Nov 11 at 23:49
not sure about it.. can you elaborate please?
– Gonras Karols
Nov 11 at 23:49
I'm guessing you didn't. see developers.google.com/drive/api/v3/reference/permissions
– pinoyyid
Nov 12 at 2:03
I'm guessing you didn't. see developers.google.com/drive/api/v3/reference/permissions
– pinoyyid
Nov 12 at 2:03
@GonrasKarols How are you going with your Google scripts problem? Worked it out, or still needing help?
– Tedinoz
Nov 23 at 21:47
@GonrasKarols How are you going with your Google scripts problem? Worked it out, or still needing help?
– Tedinoz
Nov 23 at 21:47
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225053%2fgoogle-spreadsheet-api-accessing-a-spreadsheet-created-with-service-account%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225053%2fgoogle-spreadsheet-api-accessing-a-spreadsheet-created-with-service-account%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
has your Service Account created a Permission to your User Account for the new spreadsheet?
– pinoyyid
Nov 11 at 17:25
not sure about it.. can you elaborate please?
– Gonras Karols
Nov 11 at 23:49
I'm guessing you didn't. see developers.google.com/drive/api/v3/reference/permissions
– pinoyyid
Nov 12 at 2:03
@GonrasKarols How are you going with your Google scripts problem? Worked it out, or still needing help?
– Tedinoz
Nov 23 at 21:47