I'm using native Google Plus plugin with Ionic 3 app.
Login() method is like this:
login(){
GooglePlus.login({
'webClientId': '*************************'
}).then((res) => {
console.log(res);
}, (err) => {
console.log(err);
});
}
The problem here is about the webClientId.Hence I have created 2 apps on developer console (iOS and Android), it shows 2 different webClientIds.So which value should I give to above code?
Helpful link: Ionic Google Authentication
Plugin link: enter link description here
You don't need to put webClientId in GooglePlus.login().
Your login method should be (if no additional options)-
GooglePlus.login({}).then((res) => {
console.log(res);
}, (err) => {
console.log(err);
});
iOS
You need to put REVERSED_CLIENT_ID in config.xml for iOS.
<plugin name="cordova-plugin-googleplus" spec="~5.1.1">
<variable name="REVERSED_CLIENT_ID" value="com.googleusercontent.apps.967272422526-vu37jlptokv45glo2kciu9o2rddm7gte" />
</plugin>
To find you REVERSED_CLIENT_ID, in developer console go to credentials and click on created iOS credential and Download Plist.
Android
For android you don't need any id, it works on Signing-certificate fingerprint, make sure the Signing-certificate fingerprint and Package name are correct while creating oauth client id.
If you are not signing your apk with any created keystore file then take SHA-1 signing-certificate fingerprint of default debug.keystore file.
keytool -exportcert -keystore C:\Users\Username\.android\debug.keystore -list -v
I have used most common path of debug.keystore (windows). It might be different for you, just look for .android dir.
Find your REVERSED_CLIENT_ID inside GoogleService-Info.plist from firebase.
Related
I have a React-Native app and I am using the firebase SDK for React-Native. I have just implemented App-Check for my app and it works fine in debugging mode, but it fails in Release. Here is the code for app-check in index.js which is triggered as soon as app is initialized:
try {
firebase.appCheck().setTokenAutoRefreshEnabled(true);
firebase.appCheck().activate('ignored', true);
firebase.appCheck().getToken(true).then(res => {
GLOBAL.app_check = JSON.stringify(res.token);
console.log("app check success, appchecktoken: " + JSON.stringify(res.token));
}).catch((error) => {
GLOBAL.app_check = '';
console.error("app check failed: " + error);
alert('App check failed: ' + JSON.stringify(error));
return;
});
} catch (e) {
console.log("Failed to initialize appCheck:", e);
logErrors('appCheck failed: ', e);
}
as you can see above, I am using alert to print the error message but here it what it prints:
**App check failed: {} **
.. object is empty. How can I check what's wrong with it? I am using Play Integrity and SafetyNet and I have added the SHA-252 which I got by using Gradle's Signing Report via the following command:
gradlew signingReport
What am I doing wrong here?
You will need to get the SHA-256 for all signing keys used with your app. With debug keys, calling gradlew signingReport works as it goes to the default signing key location (~/.android/debug.keystore) and runs the java keytool against this keystore supplying the default alias (android) and password (android).
For your release keys, which are self generated, you would need to use the java keytool which can generally be found on your system path or within the jdk directory. If you need help setting up keytool, I would refer to this stackoverflow question. You could use any other variations of keytool that exist, but I would use the one that ships with the jdk as its generally trusted. The command you would then want to run using keytool would be:
keytool -list -v -alias ${alias_of_keystore} -keystore ${location_of_keystore}
You would want to sub the alias and location with your own values. Using the default debug key values, the command would look something like this:
keytool -list -v -alias android -keystore ~/.android/debug.keystore
This video talks about all the different locations to grab the SHA-256. For instance, after you upload to the Google Play Store, if you opt into Google Play Signing (which I believe is the default) you will need to grab the SHA-256 from there as well. The rest of the video covers digital asset links and can be ignored.
I have been reading and reading and pouring over many different articles on how to resolve it, this this this don't forget this one
I have a firebase account already with a pre existing 0auth set up, however, I have opted to create a new authentication for android. here is what I have done
create the new app in firebase let's call it "androidAuth"
get the google-services.json file and place it within the project's root directory
in termanal run $ keytool -list -v -keystore ~/.android/debug.keystone enter password "android.
copy the SHA1 fingerprint
go back to firebase click the button that says "add fingerprint"
paste fingerprint in there.
run the application on my android device
click google sign in, the prompt for emails come up
'error --> 10'
here is the code, pretty simple:
public loginGoogle(): void {
this.google
.login({})
.then((res: any): void => {
console.log('res -->', res);
})
.catch((e: ErrorEvent): void => console.log('error -->', e));
}
thanks for any help on this.
update I've created a local keystore that is saved in the apps root folder, i added that to the firebase fingerprint list, still error 10
I'm trying to integrate The Ionic Google Plus Native Plugin to allow users to log into my app from their phone using Google Login. This is just a wrapper around this Cordova / PhoneGap library.
I think I'm just about all the way there. I have a button on my login screen and when I click it on my Android phone, I am confronted with the expected "Choose an account" screen. But when I actually do tap on one of my accounts and look at what happened in Chrome Dev Tools (by way of Remote Debugging), I see that an error resulted, cryptically denoted 12500 with a useless stack-trace.
It seems that a handful of stars need to align to get this to work, and it's not entirely clear how I can get this to work concurrently in Development and Production modes. Here's what I've checked:
In Google APIs & Services => Credentials dashboard
I have two OAuth 2.0-client IDs for Android, one is meant for Development and one is meant for Production.
Both of these are configured with the same Package name, which is the fully qualified name in the Android manifest file, named starting with "com.blah.blah.blah" which is also the widget id in the config.xml file
Each of these is configured with a different Signing-certificate fingerprint, which I established using keytool.
For Production, I generated the SHA1 fingerprint from the keystore file I use to sign the app for production.
For Development, I generated the SHA1 fingerprint by extracting the debug APK generated by ionic cordova run android, and running keytool on the contained META-INF/CERT.RSA file.
In the Ionic project's config.xml file
I have a section that looks like this:
<plugin name="cordova-plugin-googleplus" spec="^5.3.2">
<variable name="REVERSED_CLIENT_ID" value="com.googleusercontent.apps.ABCDEFG-12345" />
<variable name="WEB_APPLICATION_CLIENT_ID" value="ABCDEFG-12345.apps.googleusercontent.com" />
<variable name="PLAY_SERVICES_VERSION" value="11.8.0" />
</plugin>
I've been substituting for ABCDEFG-12345 above the Production or Development unique client id part there, I don't see a clear way to support both at once except maybe as a custom build step.
In the Typescript for the page with my login button, for now, I'm just doing this:
import { GooglePlus } from '#ionic-native/google-plus
...
constructor(public googlePlus: GooglePlus){}
...
login() {
this.googlePlus.login({
webClientId: 'ABCDEFG-12345.apps.googleusercontent.com',
offline: false
})
.then(res => console.log(res))
.catch(err => console.error(err));
}
Again here, substituting ABCDEFG-12345 above the Production or Development unique client id part there, I don't see a clear way to support both at once except maybe as a custom build step.
When I tap the button, I just get the 12500 error in Development mode. I haven't tried in Production mode. What the heck am I missing and how do I get to the bottom of it?
Cross-posted issue in github repository here.
UPDATE: 7 NOV 2018
Omitting all options from the call to this.googlePlus.login (that is, passing an empty object, {}) I don't get the error, but this.googlePlus.login, I get back a user object in response. However, I do not get back (at least on Android) an idtoken (which I can pass to my server-side code). So my object looks like this:
{
accessToken: "XXXXXXXXXXX"
displayName: "XXXXXXXXXXX"
email: "XXXXXXXXXXX"
expires: XXXXXXXXXXX
expires_in: XXXXXXXXXXX
familyName: "XXXXXXXXXXX"
givenName: "XXXXXXXXXXX"
userId: "XXXXXXXXXXXX"
}
Any ideas how to get an idtoken in the callback object?
We are using react-native-google-signIn for android in our project. We have created a project in google developer console and downloaded the google-services.json file. The google-services.json file is placed in android/apps folder.
When we configure the googleSignIn in code , am getting error: 10 code from google.
GoogleSignin.configure({
webClientId:'***********************.apps.googleusercontent.com'
})
If i don't pass the webClientId , the sign-in is successful but idToken is returned as null in the user object.
I made sure that the webClientId value is correct by following [1] and [2].
Any suggestions in this regard will be appreciated.
Your SHA-1 key may be incorrect. The comment of #mtt87 did help me:
https://github.com/devfd/react-native-google-signin/issues/224
I am using firebase and kept getting the same issue until I passed the web client_id from the firebase google-services file into the GoogleSignin.configure method.
await GoogleSignin.configure({
webClientId: '<unique string>.apps.googleusercontent.com',
});
const userInfo = await GoogleSignin.signIn();
May be there is a problem related to SHA1 key.
Make sure you have placed both debug and release SHA1 key to your firebase project.
for finding SHA1 key:
go to your android folder and hit below command
For debug mode :
keytool -keystore app/debug.keystore -list -v
For release mode:
keytool -keystore app/release.keystore -list -v
I was able to get the facebookConnectPlugin working on iOS using PhoneGap and Ionic. The issue is that when I try to run the exact same app on Android I get the error "facebookConnectPlugin is not defined". I'm using PhoneGap Build and am not building natively for Android.
Here are the steps I've taken to try to get it working on Android:
1) Generated a new keystore.
"C:\Program Files (x86)\Java\jre1.8.0_60\bin\keytool.exe" -genkey -v -keystore debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000
2) Created a new hash using this keystore.
"C:\Program Files (x86)\Java\jre1.8.0_60\bin\keytool.exe" -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64
Used the password "android" everywhere it asked me for a password (for the keystore and the hash).
3) Added the following to my config.xml document:
<gap:plugin name="com.phonegap.plugins.facebookconnect" version="0.9.0">
<param name="APP_ID" value="XXXXXXXXXX" />
<param name="APP_NAME" value="MyApp" />
</gap:plugin>
The APP_ID I got from Facebook and the APP_NAME was the display name from Facebook.
4) Created an Android key in PhoneGap build uploading the keystore I specified and the alias "androiddebugkey". For all the passwords, including the certificate password I input my password "android".
5) Uploaded my application to PhoneGap build, installed it on an Android emulator (Lollipop using Visual Studio Emulator for Android) and tried to log into Facebook using the following code. This code fires after $ionicPlatform.ready.
var _this = this;
var fbLoginSuccess = function (userData) {
facebookConnectPlugin.api("me/?fields=id,email", ["public_profile"],
function (result) {
},
function (error) {
alert("Failed: " + error);
}
);
}
facebookConnectPlugin.login(["public_profile"],
fbLoginSuccess,
function (error) {
alert(JSON.stringify(error));
}
);
6) For my site at developers.facebook.com I added an Android app. The Google Play Package Name is the same as my "id" in the widget element in config.xml. For the Class Name, I specified the exact same thing as the id, but with ".MainActivity" appended to it. I inserted the Key Hash generated from Step 2 above into the Key Hashes field. I turned Single Sign On on. Not sure if that is correct or not.
I've spent days trying to figure this out with no luck. I'm not sure if the issue is with the hash, cordova, or some other Facebook permissions. Like I said earlier, it works fine on iOS. It's just Android that has the problem.
Any help would be very much appreciated.
#oalbrecht,
I am posting this link with the hope you will read the entire document.
Top Mistakes by Developers new to Cordova/Phonegap
In fact your error was
3. Does not follow the blogs.
For you see, we have now move to a new repository on npm.org. This actually gets you another error
11. You need to get your plugins from NPM now.
How did I figure this out? I did a google search of your plugin: com.phonegap.plugins.facebookconnect
About three (3) links down is your plugin: FacebookConnect
The documentation says
REPOSITORY IS NOW DEPRECATED!!!
Please go here
READ THE DIRECTIONS CAREFULLY. This is an ugly plugin. The correct links are:
github
npm
Your new plugin setting is:
<gap:plugin name="cordova-plugin-facebookconnect-orlando" source="npm" version="0.11.0">