Why is my google account authentication failing?
I have created a scraping application ( C# ) that writes results to a private Google Sheet.
When I run the application in Debug mode, it works as expected and authenticates.
However, when I run it as a task, the authentication fails here...
using (var stream =
new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
string credPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials/sheets.googleapis.com-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
I have a credentials.json file set to copy always in the project and it is being copied to the bin/debug and bin/release folders on compilation.
The error I am getting (only when run in task scheduler) is this....
Unhandled Exception: System.IO.FileNotFoundException: Could not find file
'C:WINDOWSsystem32credentials.json'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access,
Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize,
FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean
bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at ScreenScraper.Program.AuthorizeGoogleApp() in
C:UsersxxxDocumentsVisual Studio
2017ProjectsScreenScraperScreenScraperProgram.cs:line 74
at ScreenScraper.Program.Main(String args) in C:UsersxxxDocumentsVisual
Studio 2017ProjectsScreenScraperScreenScraperProgram.cs:line 38
I then copied credentials.json to C:WINDOWSsystem32 but I am still getting the error.
c# .net google-sheets google-authentication google-api-dotnet-client
|
show 4 more comments
I have created a scraping application ( C# ) that writes results to a private Google Sheet.
When I run the application in Debug mode, it works as expected and authenticates.
However, when I run it as a task, the authentication fails here...
using (var stream =
new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
string credPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials/sheets.googleapis.com-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
I have a credentials.json file set to copy always in the project and it is being copied to the bin/debug and bin/release folders on compilation.
The error I am getting (only when run in task scheduler) is this....
Unhandled Exception: System.IO.FileNotFoundException: Could not find file
'C:WINDOWSsystem32credentials.json'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access,
Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize,
FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean
bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at ScreenScraper.Program.AuthorizeGoogleApp() in
C:UsersxxxDocumentsVisual Studio
2017ProjectsScreenScraperScreenScraperProgram.cs:line 74
at ScreenScraper.Program.Main(String args) in C:UsersxxxDocumentsVisual
Studio 2017ProjectsScreenScraperScreenScraperProgram.cs:line 38
I then copied credentials.json to C:WINDOWSsystem32 but I am still getting the error.
c# .net google-sheets google-authentication google-api-dotnet-client
Permission issue perhaps?
– just-my-name
Nov 21 '18 at 19:39
Possibly - I gave full read permission to the folder - same error
– Greg
Nov 21 '18 at 19:45
I suggest you choode a different path tham Environment.SpecialFolder.Personal, e.g. Environment.SpecialFolder.CommonAppData
– Klaus Gütter
Nov 21 '18 at 19:47
@KlausGütter - I tried that - same error : Could not find file 'C:WINDOWSsystem32credentials.json
– Greg
Nov 21 '18 at 19:52
When I run the exe directly from the bin/debug it works ... so must be a setting in the task scheduler
– Greg
Nov 21 '18 at 19:57
|
show 4 more comments
I have created a scraping application ( C# ) that writes results to a private Google Sheet.
When I run the application in Debug mode, it works as expected and authenticates.
However, when I run it as a task, the authentication fails here...
using (var stream =
new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
string credPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials/sheets.googleapis.com-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
I have a credentials.json file set to copy always in the project and it is being copied to the bin/debug and bin/release folders on compilation.
The error I am getting (only when run in task scheduler) is this....
Unhandled Exception: System.IO.FileNotFoundException: Could not find file
'C:WINDOWSsystem32credentials.json'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access,
Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize,
FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean
bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at ScreenScraper.Program.AuthorizeGoogleApp() in
C:UsersxxxDocumentsVisual Studio
2017ProjectsScreenScraperScreenScraperProgram.cs:line 74
at ScreenScraper.Program.Main(String args) in C:UsersxxxDocumentsVisual
Studio 2017ProjectsScreenScraperScreenScraperProgram.cs:line 38
I then copied credentials.json to C:WINDOWSsystem32 but I am still getting the error.
c# .net google-sheets google-authentication google-api-dotnet-client
I have created a scraping application ( C# ) that writes results to a private Google Sheet.
When I run the application in Debug mode, it works as expected and authenticates.
However, when I run it as a task, the authentication fails here...
using (var stream =
new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
string credPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials/sheets.googleapis.com-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
I have a credentials.json file set to copy always in the project and it is being copied to the bin/debug and bin/release folders on compilation.
The error I am getting (only when run in task scheduler) is this....
Unhandled Exception: System.IO.FileNotFoundException: Could not find file
'C:WINDOWSsystem32credentials.json'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access,
Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize,
FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean
bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at ScreenScraper.Program.AuthorizeGoogleApp() in
C:UsersxxxDocumentsVisual Studio
2017ProjectsScreenScraperScreenScraperProgram.cs:line 74
at ScreenScraper.Program.Main(String args) in C:UsersxxxDocumentsVisual
Studio 2017ProjectsScreenScraperScreenScraperProgram.cs:line 38
I then copied credentials.json to C:WINDOWSsystem32 but I am still getting the error.
c# .net google-sheets google-authentication google-api-dotnet-client
c# .net google-sheets google-authentication google-api-dotnet-client
edited Nov 21 '18 at 21:10
TheMaster
9,9953732
9,9953732
asked Nov 21 '18 at 19:36
GregGreg
1,72832644
1,72832644
Permission issue perhaps?
– just-my-name
Nov 21 '18 at 19:39
Possibly - I gave full read permission to the folder - same error
– Greg
Nov 21 '18 at 19:45
I suggest you choode a different path tham Environment.SpecialFolder.Personal, e.g. Environment.SpecialFolder.CommonAppData
– Klaus Gütter
Nov 21 '18 at 19:47
@KlausGütter - I tried that - same error : Could not find file 'C:WINDOWSsystem32credentials.json
– Greg
Nov 21 '18 at 19:52
When I run the exe directly from the bin/debug it works ... so must be a setting in the task scheduler
– Greg
Nov 21 '18 at 19:57
|
show 4 more comments
Permission issue perhaps?
– just-my-name
Nov 21 '18 at 19:39
Possibly - I gave full read permission to the folder - same error
– Greg
Nov 21 '18 at 19:45
I suggest you choode a different path tham Environment.SpecialFolder.Personal, e.g. Environment.SpecialFolder.CommonAppData
– Klaus Gütter
Nov 21 '18 at 19:47
@KlausGütter - I tried that - same error : Could not find file 'C:WINDOWSsystem32credentials.json
– Greg
Nov 21 '18 at 19:52
When I run the exe directly from the bin/debug it works ... so must be a setting in the task scheduler
– Greg
Nov 21 '18 at 19:57
Permission issue perhaps?
– just-my-name
Nov 21 '18 at 19:39
Permission issue perhaps?
– just-my-name
Nov 21 '18 at 19:39
Possibly - I gave full read permission to the folder - same error
– Greg
Nov 21 '18 at 19:45
Possibly - I gave full read permission to the folder - same error
– Greg
Nov 21 '18 at 19:45
I suggest you choode a different path tham Environment.SpecialFolder.Personal, e.g. Environment.SpecialFolder.CommonAppData
– Klaus Gütter
Nov 21 '18 at 19:47
I suggest you choode a different path tham Environment.SpecialFolder.Personal, e.g. Environment.SpecialFolder.CommonAppData
– Klaus Gütter
Nov 21 '18 at 19:47
@KlausGütter - I tried that - same error : Could not find file 'C:WINDOWSsystem32credentials.json
– Greg
Nov 21 '18 at 19:52
@KlausGütter - I tried that - same error : Could not find file 'C:WINDOWSsystem32credentials.json
– Greg
Nov 21 '18 at 19:52
When I run the exe directly from the bin/debug it works ... so must be a setting in the task scheduler
– Greg
Nov 21 '18 at 19:57
When I run the exe directly from the bin/debug it works ... so must be a setting in the task scheduler
– Greg
Nov 21 '18 at 19:57
|
show 4 more comments
1 Answer
1
active
oldest
votes
In actions change optional start up to the folder path.
Actions > Edit > Program/script = YOurGoogle.exe > Start in (Optional) > eg.C:UsersMe
add a comment |
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',
autoActivateHeartbeat: false,
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%2f53419389%2fwhy-is-my-google-account-authentication-failing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In actions change optional start up to the folder path.
Actions > Edit > Program/script = YOurGoogle.exe > Start in (Optional) > eg.C:UsersMe
add a comment |
In actions change optional start up to the folder path.
Actions > Edit > Program/script = YOurGoogle.exe > Start in (Optional) > eg.C:UsersMe
add a comment |
In actions change optional start up to the folder path.
Actions > Edit > Program/script = YOurGoogle.exe > Start in (Optional) > eg.C:UsersMe
In actions change optional start up to the folder path.
Actions > Edit > Program/script = YOurGoogle.exe > Start in (Optional) > eg.C:UsersMe
answered Nov 22 '18 at 23:46
Josh CraigJosh Craig
1
1
add a comment |
add a comment |
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.
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%2f53419389%2fwhy-is-my-google-account-authentication-failing%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
Permission issue perhaps?
– just-my-name
Nov 21 '18 at 19:39
Possibly - I gave full read permission to the folder - same error
– Greg
Nov 21 '18 at 19:45
I suggest you choode a different path tham Environment.SpecialFolder.Personal, e.g. Environment.SpecialFolder.CommonAppData
– Klaus Gütter
Nov 21 '18 at 19:47
@KlausGütter - I tried that - same error : Could not find file 'C:WINDOWSsystem32credentials.json
– Greg
Nov 21 '18 at 19:52
When I run the exe directly from the bin/debug it works ... so must be a setting in the task scheduler
– Greg
Nov 21 '18 at 19:57