Closed MasterJubei closed 3 years ago
Hi @MasterJubei, make sure you go through the pre-requisite for google auth and fill all the details correctly on the google console page. This error generally comes up when the package name or SHA key is mismatched.
Hi @shashi278 Thanks a lot, I believe you are correct.
For anyone else, I believe this should resolve that issue. https://github.com/shashi278/social-auth-kivy/blob/master/docs/prerequisites.md
To generate a keystore file, I recommend just using Ubuntu/linux rather than Windows Java. I am just saying this because I first tried it with Windows and it didn't work BUT I could have easily just made a typo.
In buildozer I have
# (str) Title of your application
title = imgUpload
# (str) Package name
package.name = imgUpload
# (str) Package domain (needed for android/ios packaging)
package.domain = com.dslice
So my full package name is com.dslice.imgupload
To generate a keystore: https://stackoverflow.com/questions/3997748/how-can-i-create-a-keystore
For me I ran: (imgupload is my program name)
keytool -genkey -v -keystore newkey.keystore -alias imgupload -keyalg RSA -keysize 2048 -validity 10000
Then in the same directory as the newkey.keystore
keytool -keystore newkeystore.key -list -v
Put that in the google cloud form which asks for the SHA1 fingerprint.
Then in your code add:
GOOGLE_CLIENT_ID = (
"394092214639-xxxxxxxxxxxx.apps.googleusercontent.com"
)
GOOGLE_CLIENT_SECRET = "secret"
And follow the example provided https://github.com/shashi278/social-auth-kivy/blob/master/demo/main.py
I also added the export P4A commands, I am fairly sure you to run those before running buildozer in the same terminal session.
https://github.com/kivy/kivy/wiki/Creating-a-Release-APK
From here before building the latest version of my app, I beleive it has to be a release, not debug. So make sure you run with
buildozer -v android release
Then it seems to work
07-05 00:10:58.063 11374 11374 I python : [INFO ] [KivyAuth ] Google Login success. Calling success listener.
07-05 00:10:58.192 11374 11374 W SDLThread: type=1400 audit(0.0:135768): avc: granted { execute } for path="/data/user/0/com.dslice.imgupload/files/app/_python_bundle/modules/unicodedata.cpython-38.so" dev="dm-8" ino=106083 scontext=u:r:untrusted_app_27:s0:c168,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c168,c257,c512,c768 tclass=file app=com.dslice.imgupload
However I am facing one issue so far,
I am trying to replace an image with the google login one, but I get
[WARNING] [GL ] Unpack subimage support is not available
my after_login is
def after_login(self, name, email, photo_uri):
self.user_avatar = AsyncImage(source = photo_uri)
self.user_avatar.reload()
It just has the old picture though. I might be doing something wrong though.
Then in your code add:
GOOGLE_CLIENT_ID = ( "394092214639-xxxxxxxxxxxx.apps.googleusercontent.com" ) GOOGLE_CLIENT_SECRET = "secret"
You don't need to add client ID and secret if you're only targeting android. Those are only required for desktop.
From here before building the latest version of my app, I beleive it has to be a release, not debug. So make sure you run with
buildozer -v android release
You don't need to build it for release if you're only testing it out on your device.
However I am facing one issue so far,
I am trying to replace an image with the google login one
Shouldn't it be possible by simply using a new instance of AsyncImage
? I'm not sure why you doing a reload
.
Thanks for the tips. I got it after messing with it a bit. Before the code was a bit odd. I already had an AsyncImage loaded by default. But in the code above I was basically linking self.user_avatar to a new AsyncImage instead of replacing the current one's image.
So with that:
def after_login(self, name, email, photo_uri):
if platform == "android":
show_toast("Logged in using {}".format(self.current_provider))
self.user_avatar.source = photo_uri
self.user_avatar.reload()
Thanks for the help! You are also correct that I do not have to make a release version. I also went ahead and removed the google_client_id code and it still works as you mentioned on Android.
I really appreciate you for making this library!
Also I should add, for me buildozer did not always seem to use the P4A values I specified.
But what I can do is get the SHA1 fingerprint from the output .apk file
keytool -printcert -jarfile imgupload-0.1-armeabi-v7a-debug.apk
Gives me the fingerprint so I can put that in google cloud
Glad it worked!
Also I should add, for me buildozer did not always seem to use the P4A values I specified.
It should. What fields you think are not working? Also it's recommended to get your SHA from the keystore you've created because I believe apk fingerprint can be changed sometimes, for example, when uploading your app to playstore and opting for 'let Google sign my apk'(which is recommended in play console) option.
The SHA1 fingerprint was being used from my keystore, and that is put on google cloud. But for some reason my output for the apk stopped using them. I am not sure why this is. I was using the same terminal session back when it originally was working. Buildozer also is respecting the P4A commands in some way at least because if I put a nonexistant keystore with
export P4A_RELEASE_KEYSTORE=~/keystores/<your-new-key>.keystore
it will complain.
So for now I have both the keystore fingerprint and the apk file's fingerprint on google cloud. They should be the same, but I am not sure what's going on there.
So they're not same? Again I'm not sure why you'd be exporting release keystore if you're only testing out your apk in debug mode.
Also something to note, if you're creating a release version of you app and uploading it to the play store and opting for 'let Google sign my apk' then you'd need to add/update the Google provided SHA into your Google cloud console for your app otherwise it won't work because the app on play store won't have your local SHA anymore. This is a very common mistake that, I guess, most people make when working with social authentication. You'd need to update your SHA everywhere if you're using Facebook Auth, firebase(Github and Twitter) Auth for your app to work after releasing it to the playstore. It think this info should be in the Readme as well
Oh, that's probably it... I assume I should be using something like P4A_DEBUG_KEYSTORE instead right? (Since I am running the app in debug mode for now)
Keystore is used to sign your application and you need to sign your application only when you're building the release version so that when you update your application, the play console knows that it's from you. When you build release version of your application using buildozer, it expects those environment variables to be set(exported). No such requirements for building debug app.
Then in your code add:
GOOGLE_CLIENT_ID = ( "394092214639-xxxxxxxxxxxx.apps.googleusercontent.com" ) GOOGLE_CLIENT_SECRET = "secret"
You don't need to add client ID and secret if you're only targeting android. Those are only required for desktop.
From here before building the latest version of my app, I beleive it has to be a release, not debug. So make sure you run with
buildozer -v android release
You don't need to build it for release if you're only testing it out on your device.
However I am facing one issue so far, I am trying to replace an image with the google login one
Shouldn't it be possible by simply using a new instance of
AsyncImage
? I'm not sure why you doing areload
.
I've same issue as @MasterJubei had. But as you said CLIENT_ID and CLIENT_SECRET are not needed for android only. That should mean that we don't need SHA-1 hash or any app in cloud console? But, even after I tried to get hash I get same error message as his. Also as you said release is not needed for app if it just needs to be tested then why my app is still not working can you tell?
But as you said CLIENT_ID and CLIENT_SECRET are not needed for android only. That should mean that we don't need SHA-1 hash or any app in cloud console?
It does not mean that. You'd need to add correct hash and package name in the cloud console.
But as you said CLIENT_ID and CLIENT_SECRET are not needed for android only. That should mean that we don't need SHA-1 hash or any app in cloud console?
It does not mean that. You'd need to add correct hash and package name in the cloud console.
I did that still I'm getting same error. When setting package name in the cloud console in the package name section we'll set it equal to package name that we set in buildozer.spec like package.name = ProjectRed
?
You don't need to add client ID and secret if you're only targeting android. Those are only required for desktop.
Can you make it clear as you are saying that it's not needed to add client id and secret here? [EDIT] Now, I got it.
So, I finally understood what do, If anybody still has this issue while making debug app then refer #19
Hi, thanks for making this
The demo app works on the playstore for me. However I cannot seem to get it to work. I created a google cloud oauth2 credentials for android. I then get my clientid.
In the code, I replaced GOOGLE_CLIENT_ID with my own string. I left the google_client_secret as "secret" since I do not think that gets used?
However when I run it, and then click on my google account and it tries to login. I get:
My build looks the same,
Right now the top of my code looks like (edited the google client ID a bit):