B4A Library GSheet Library (integrate google sheets into your B4X apps easily)

fernando1987

Active Member
Licensed User
Dear Abbas818,

I’m pleased to inform you that the GSheets library has been succe

To download it, please follow these s

Log in to your account at https://b4xapp.com
Go to the "My Purchases" sectio
Look for the GSheets library and click on the download link.
For more detailed instructions, you can refer to this article:
If you encounter any issues or need assistance, feel free to reach out to me. I’ll be happy to
 
Last edited:

Abbas818

Member
Thanks a lot you Fernando
I appreciate your kindness.
 

Abbas818

Member
Dear Fernando
Thanks for sharing your good library
Unfortunatly I am beginer in B4A.
I tried to use Gsheetplus library. I only want to read and write a string value in a specefic cell for example Cell A5 in a sheet. I saw your example "hojs-de-google" but it is very complicated for me.
Can you please share me a simple example to read and write to a specefic cell?
Thanks
 

fernando1987

Active Member
Licensed User
The example clearly demonstrates the four main functions: read, update, write, and delete. However, it is essential to first configure a home screen in your Google Console, generate the required keys, and enable permissions for the necessary APIs.

Remember that your application's name must be linked to the API key you generated. It is recommended to follow the tutorial videos mentioned in the first post and ensure the package name matches the one assigned to the generated key. Please verify and correctly configure your Google Cloud Console to ensure everything works as expected.


 

Abbas818

Member
Don't forget this
View attachment 159657

Also enable the Google Drive API and the Google Shets API.
Dear Fernando
I followed the instruction and tried to test your example. It runs but when it wants to connect to my account and I confirm it , the browser open google.com and nothing happens. Whenever i use the app this will happens. Please see the file I attached.
 

Abbas818

Member
 

Attachments

  • Screenshot_20241220_131750.jpg
    244 KB · Views: 208
  • Screenshot_20241220_131812_Chrome.jpg
    200 KB · Views: 219
  • Screenshot_20241220_131826_Chrome.jpg
    329 KB · Views: 217
  • Screenshot_20241220_131845_Chrome.jpg
    387.6 KB · Views: 198
  • Screenshot_20241220_131916_Chrome.jpg
    139.3 KB · Views: 202
  • Screenshot_20241220_131931.jpg
    161.5 KB · Views: 204
  • Screenshot_20241220_131944.jpg
    127.8 KB · Views: 204

fernando1987

Active Member
Licensed User
Hello, could you please send me the code, the example that you modified and with which you have problems, so I can review it?
 

fernando1987

Active Member
Licensed User
Here is a functional example that creates a spreadsheet in Google Sheets, saves its ID and name in a database, and specifically modifies the value of cell A5 in the generated sheet.

Example Explanation:

  1. Spreadsheet Creation:
    The example uses the Google Sheets API tools to create a new spreadsheet. Once created, its unique ID and assigned name are retrieved.
  2. Database Storage:
    The spreadsheet's ID and name are saved in a database for future management and reference. This simplifies linking it to other operations or applications.
  3. Modifying Cell A5:
    After creating the spreadsheet, the code directly accesses cell A5 and updates its content to a specific value. This step demonstrates how to interact with specific cells within a spreadsheet.
This example is perfect for understanding how to automate the creation, management, and updating of spreadsheets through code while integrating them with a database for more efficient control.
 

Attachments

  • ejample.zip
    11 KB · Views: 187

fernando1987

Active Member
Licensed User

Version 9.5 Now Available!

We’re excited to announce the release of Version 9.5 with significant code corrections and performance enhancements!

How to Download the Update:​

If you’ve already purchased a previous version, simply log in to your user panel on our store at b4xapp.com using your credentials.

  1. Navigate to the "Recent Orders" section.
  2. Locate your purchase of Gsheets or GsheetsPlus.
  3. Click the download option to get the latest version at no additional cost.
Enjoy the improvements and let us know what you think!


Limited-Time Offer!
Take advantage of 50% OFF on all codes and libraries in our store until January 5, 2025! Don't miss this opportunity to expand your toolkit at half the price.

Visit b4xapp.com now and save big!
 

DonManfred

Expert
Licensed User
Longtime User

fernando1987

Active Member
Licensed User
I apologize for the earlier inconvenience; the link is now active again and accessible. You can view it without any issues. In fact, all my libraries related to API integrations are developed using that program because it has the capability to generate the necessary B4X code for seamless API communication. Its efficiency and compatibility have been instrumental in my development workflow.
 

Mr_fifty4

Member
Licensed User
Longtime User
Hi Fernando,

I purchased your gsheetplus library and i'm trying with your example for b4j.
after connect with google i got this errors:

WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
Getting access token from authorization code...
java.lang.NoSuchMethodError: 'java.lang.String b4j.example.httpjob._initialize(b4j.example.httpjob, anywheresoftware.b4a.BA, java.lang.String, java.lang.Object)'
at b4j.example.googleoauth2$ResumableSub_GetTokenFromAuthorizationCode.resume(googleoauth2.java:758)
at b4j.example.googleoauth2._gettokenfromauthorizationcode(googleoauth2.java:723)
at b4j.example.googleoauth2._parsebrowserurl(googleoauth2.java:941)
at b4j.example.googleoauth2$ResumableSub_PrepareServer.resume(googleoauth2.java:456)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1050)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:832)
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NoSuchMethodError: 'java.lang.String b4j.example.httpjob._initialize(b4j.example.httpjob, anywheresoftware.b4a.BA, java.lang.String, java.lang.Object)'
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1052)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: 'java.lang.String b4j.example.httpjob._initialize(b4j.example.httpjob, anywheresoftware.b4a.BA, java.lang.String, java.lang.Object)'
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:140)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1050)
... 7 more
Caused by: java.lang.NoSuchMethodError: 'java.lang.String b4j.example.httpjob._initialize(b4j.example.httpjob, anywheresoftware.b4a.BA, java.lang.String, java.lang.Object)'
at b4j.example.googleoauth2$ResumableSub_GetTokenFromAuthorizationCode.resume(googleoauth2.java:758)
at b4j.example.googleoauth2._gettokenfromauthorizationcode(googleoauth2.java:723)
at b4j.example.googleoauth2._parsebrowserurl(googleoauth2.java:941)
at b4j.example.googleoauth2$ResumableSub_PrepareServer.resume(googleoauth2.java:456)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
... 11 more


GSheetplus ver 9.50

Can help me to solve?

thanks
 

fernando1987

Active Member
Licensed User
Hi,

Thank you for reaching out and for purchasing the GSheetPlus library.

The issue you're experiencing might be related to the Google API configuration. Please review the following steps to ensure everything is set up correctly:

1. Google Cloud Console Setup:

Ensure you created the OAuth 2.0 Client ID in the Google Cloud Console.

Replace the client ID and client secret in the example project with the ones provided in the console.

Verify that the redirect URI matches the one used in the example code.



2. Google Sheets and Drive API Activation:

In your Google Cloud Console project, make sure the Google Sheets API and Google Drive API are enabled.



3. Authorization Screen:

Confirm that you have configured the OAuth consent screen properly in the Cloud Console.

Ensure you have added the necessary permissions (scopes) for Drive



4. Permissions:

When authorizing your app, make sure you grant all requested permissions. If you denied any permission during the process, it might cause the token retrieval to fail.



5. Dependencies:

Ensure you have the latest versions of the HttpJob and OkHttpUtils2 libraries in your B4J project. Using outdated libraries can cause errors.



6. Logs:

If the issue persists, check the logs to verify if the authorization code is being received or if the issue occurs during the token exchange process.


Best regards,
Fernando
 

Mr_fifty4

Member
Licensed User
Longtime User

Solved:
following your example and the video I didn't check if the B4J package name (example) and the google user (Connectsheet) matched.

thanks Fernando
 

fernando1987

Active Member
Licensed User
Solved:
following your example and the video I didn't check if the B4J package name (example) and the google user (Connectsheet) matched.

thanks Fernando
Thank you for your feedback and for sharing how you solved the issue. I’m glad you were able to identify the mismatch between the B4J package name and the Google user configuration it’s a detail that can sometimes go unnoticed.

I’d like to take a moment to apologize if my earlier comments didn’t fully acknowledge the complexity of Google’s implementation process. While the GSheet library itself is straightforward to use, I understand that the integration with Google’s system can be challenging and requires a certain level of technical knowledge to implement effectively.

Though the video tutorials may not be perfect, they are intended to provide a basic foundation and serve as a starting point for users. Your experience highlights the importance of paying attention to all the details, and I appreciate you pointing that out.

Best regards,
Fernando
 

Mr_fifty4

Member
Licensed User
Longtime User
Hi Fernando,

after test with B4J (that work well) i start with your android example where i changed only the package name in "com.b4a.sheet" and add a new android user (following your video) in google console. This time package name are the same in app and console plus set URI_redirect flag as your indication.
During google authentication after confirm drive permission i got "Error 400: redirect_uri_mismatch".
Where i can check this issue?
Tanks a lot for you help and patience (google platform is a nightmare for me... )
 

fernando1987

Active Member
Licensed User


Hi,
The error "Error 400: redirect_uri_mismatch" typically occurs when the redirect URI in your Google Cloud Console doesn't match the one being used by your application during authentication. Here are a few key points to verify and adjust to resolve the issue:

1. Check the Package Name and SHA-1

  • Ensure the package name you registered in Google Cloud Console matches exactly with the one in your Android app (com.b4a.sheet in this case).
  • Verify that the SHA-1 certificate fingerprint of your app’s signing key is correctly added in Google Cloud Console. This must correspond to the active keystore used to sign your APK (either the debug keystore or the release keystore, depending on your build).

2. Check the Redirect URI in Your Code

  • Confirm that the redirect URI used during the OAuth flow matches exactly with the one registered in Google Cloud Console.
 

Mr_fifty4

Member
Licensed User
Longtime User
hi,
check 1 is verified,
for check 2 in "hoja_de_google" example code where i can check this point?

thanks.
 

fernando1987

Active Member
Licensed User
hi,
check 1 is verified,
for check 2 in "hoja_de_google" example code where i can check this point?

thanks.
  1. Go to the Google Cloud Console.
  2. Navigate to the Credentials section.
  3. Select the key or credential you created for your application.
  4. At the bottom, in the advanced settings, you’ll find an option called Custom URI Scheme.
For it to work properly with B4A, this custom URI scheme must be enabled, even though Google mentions that it’s not recommended. Without this configuration, the integration may fail.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…