I'm trying to syncronize my blazor server Net 8 application with google calendar to load all events and convert them in a syncfusion calendar where I can add more fields and information
I started from your description here
https://www.syncfusion.com/blogs/post/synchronize-google-calendar-with-syncfusion-blazor-scheduler
then I used this project from GitHub as starting demo
I also updated the libraries to work with at least net core 6 (instead of 3.1 of the original demo)
I suppose I well configured the Google Cloud settings to create the credentials.json file because when I started this demo from my PC inside VisualStudio it works fine and I can show in your calendar my Google calendar events.
But when I published the demo inside a shared hosting where I usually work, the application stucks on this line of code without any error message in background
Service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName });
inside the GoogleService class
The web page stucks and I can't click anywhere. I can only refresh the page to go to other pages.
I noticed that the token from Google is saved inside a folder named token.json so I created this folder inside the shared hosting disk but no files are created inside from google and this folder has write privileges to everyone
Do you know what could be the problem ?
Hi Walter Martin,
We suspect that you
are hosting on the IIS server. To resolve the issue you're facing with Google
Calendar synchronization in the published application on IIS, here are a few
possible solutions you can try:
1. File Permission Issues:
The issue might be related to file permissions when trying to write to the token.json file on the local IIS server. In IIS, the application pool identity (e.g., IIS AppPool\YourAppPoolName) might not have write permissions to the directory.
Solution:
2. Check Application Pool Identity:
Ensure that the application pool identity has the correct permissions to access files and directories. The default identity is often set to ApplicationPoolIdentity, which might not have sufficient rights.
Solution:
3. Relative Path Issues:
When running in IIS, the relative paths may not work as expected, particularly if the application is running from a different location than when executed directly in Visual Studio.
Solution:
4. Check for Errors in IIS Logs:
IIS might be blocking or throwing errors that prevent saving the token. Check the IIS logs or the application logs for any detailed errors.
Solution:
Furthermore, if there is a possibility that we have misunderstood your requirement, we would greatly appreciate it if you could provide us with additional information on this. This will help us align our understanding with your expectations and provide you with the best possible assistance.
To better assist you, could you please provide the following:
This will help us diagnose the issue more effectively and provide a more accurate solution.
Let us know, and we’ll be happy to assist further!
Regards,
Ashok
First of all many thanks for these informations
I'm hosted in IIS server in a hosting environment so I don't have a direct access to IIS configuration
I can ask for any error log to the hosting provider.
This is what I did after reading your suggestion:
1) I set in the hosting panel the "full control" to "everyone" in the "www" folder
2) Since I don't find in the Google documentation if the folders and files must be created with relative or absolute path, I saved their "credentials.json" file inside "www" and also into "wwwroot" folders
As you can see in the relevent piece of code below in bold, Google let me choose the folder name where Google will write inside his token
I have chosen "gtoken" as folder name and thanks to the steps 1 and 2 above, I can see now that the folder "gtoken" is created in the hosting environment but unfortunately without any token file inside. In my personal PC, running the application in Visual Studio, the folder "gtoken" is either created and google write inside his token successfully
for this reason I think now the application can't complete the line in bold below because it's not able to write the token inside "gtolen" folder and I don't know why since "gtolen" folder is created under "www" folder where everyone has "full control" permission
UserCredential credential;
using (FileStream stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.FromStream(stream).Secrets, Scopes, "fzuser", CancellationToken.None, new FileDataStore("gtoken", true)).Result;
}
try
{
Service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName });
}
catch (Exception ex)
{
ElmahCore.ElmahExtensions.RaiseError(ex);
}
I can I add in attachment a sample code that is not exactly my project but it's a sample I found on the web to syncronize the Google Calendar with your Scheduler
I removed from the project only the token generated by google when the application runs from Visualsudio inside the token.json folder and the file credentials.json file from the root folder with my data
This application doesn't generate the google's token when running on a Shared Hosting where I can't access to IIS log instead, If I run it on my PC from VisualStudio everything works
Is there any other suggestion on this ? it's still not working...
when I call in my app from Visual studio che function to get the Google calendar events, the line of code below, calls this page
https://accounts.google.com/o/oauth2/auth?client_id={client_id}&response_type=token&redirect_uri={redirect_uri}&scope={scope}
in a new browser sheet and shows me which google account I want to use. After selectiing my account, my application starts to read the google calendar events.
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.FromStream(stream).Secrets, Scopes, "fzuser", CancellationToken.None, new FileDataStore("gtoken", true)).Result;
When I call the same function in the same app published in a shared server, this line of code simply freezes, without any error message in console and it doesn't show me this page
https://accounts.google.com/o/oauth2/auth?client_id={client_id}&response_type=token&redirect_uri={redirect_uri}&scope={scope}
The folder I decided to use: "gtoken" is created correctly inside the sared hosting environment so the web user has rights to write on the server but inside the "gtoken" folder it doesn't create the token file. What could prevent my web app to open another web page ?
Hi Walter Martin
We are currently validating this issue and will need until January 27, 2025, to complete the validation process. Thank you for your continued support; we will update you by January 27, 2025. We apologize for any inconvenience caused and appreciate your understanding.
Regards,
Ashok
<ItemGroup> <Content Include="token.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> </Content> </ItemGroup> |