Giter Site home page Giter Site logo

eddyverbruggen / cordova-plugin-googleplus Goto Github PK

View Code? Open in Web Editor NEW
568.0 49.0 631.0 24.96 MB

:heavy_plus_sign: Cordova plugin to login with Google Sign-In on iOS and Android

Objective-C 19.89% JavaScript 33.16% Java 46.95%
google-sign google-sign-in cordova phonegap

cordova-plugin-googleplus's Introduction

Google Sign-In Cordova/PhoneGap Plugin

NPM version Downloads Twitter Follow

⚠️ From plugin version 6.0.0 the minimum required cordova-ios version is 4.5.0. Need to use a lower cordova-ios version? Use plugin version 5.3.2 or lower.

0. Index

  1. Description
  2. Screenshots
  3. Google API setup
  4. Installation (CLI / Plugman)
  5. Installation (PhoneGap Build)
  6. Installation (iOS and Cocoapods)
  7. Usage
  8. Exchanging the idToken
  9. Exchanging the serverAuthCode
  10. Troubleshooting
  11. Changelog

1. Description

This plugin allows you to authenticate and identify users with Google Sign-In on iOS and Android. Out of the box, you'll get email, display name, given name, family name, profile picture url, and user id. You can also configure it to get an idToken and serverAuthCode.

This plugin only wraps access to the Google Sign-In API. Further API access should be implemented per use-case, per developer.

2. Screenshots

Android

   

iOS

     

3. Google API setup

To communicate with Google you need to do some tedious setup, sorry.

It is (strongly) recommended that you use the same project for both iOS and Android.

Before you proceed

Go into your config.xml and make sure that your package name (i.e. the app ID) is what you want it to be. Use this package name when setting up iOS and Android in the following steps! If you don't, you will likely get a 12501, 'user cancelled' error despite never cancelling the log in process.

This step is especially important if you are using a framework such as Ionic to scaffold out your project. When you create the project, the config.xml has a placeholder packagename, e.g. com.ionic.*, so you can start developing right away.

<?xml version='1.0' encoding='utf-8'?>
<widget id="** REPLACE THIS VALUE **" ...>
...
</widget>

Browser

Browser platform require a valid WEB_APPLICATION_CLIENT_ID that generated at Google Developer Console. Ensure you have added your url address (example: http://localhost:3000) to Authorized JavaScript origins section. See this screenshot for example

iOS

To get your iOS REVERSED_CLIENT_ID, generate a configuration file here. This GoogleService-Info.plist file contains the REVERSED_CLIENT_ID you'll need during installation. This value is only needed for iOS.

The REVERSED_CLIENT_ID is also known as the "iOS URL Scheme" on the Developer's Console.

Login on iOS takes the user to a SafariViewController through the Google SDK, instead of the separate Safari browser.

Android

To configure Android, generate a configuration file here. Enable Google Sign-In and add an Android App to add the SHA1 fingerprint. Once Google Sign-In is enabled Google will automatically create necessary credentials in Developer Console for web and Android. There is no need to add the generated google-services.json file into your cordova project. You may need to configure the consent screen.

Make sure you execute the keytool steps as explained here or authentication will fail (do this for both release and debug keystores).

IMPORTANT:

  • The step above, about keytool, show 2 types of certificate fingerprints, the Release and the Debug, when generating the configuration file, it's better to use the Debug certificate fingerprint, after that, you have to go on Google Credentials Manager, and manually create a credential for OAuth2 client with your Release certificate fingerprint. This is necessary to your application work on both Development and Production releases.
  • Ensure that you are using the correct alias name while generating the fingerprint.
$ keytool -exportcert -keystore <path-to-debug-or-production-keystore> -list -v -alias <alias-name>

Login on Android will use the accounts signed in on the user's device.

Integrating Google Play Services

To set up Google Play Services version, you can use PLAY_SERVICES_VERSION parameter (with 11.8.0 value by default). It is useful in order to avoid conflicts with another plugins which use any other different version of Google Play Service, because they MUST be the same version.

Publishing your app in Google Play Store

Google re-signs your app with a different certificate when you publish it in the Play Store. Once your app is published, copy the SHA-1 fingerprint of the "App signing certificate", found in the "App signing" section under "Release Management", in Google Play Console. Paste this fingerprint in the Release OAuth client ID in Google Credentials Manager.

Web Client Id

If you want to get an idToken or serverAuthCode back from the Sign In Process, you will need to pass the client ID for your project's web application. This can be found on your project's API credentials page on the Google Developer's Console.

4. Installation (PhoneGap CLI / Cordova CLI)

This plugin is compatible with:

Here's how it works (backup your project first!):

Using the Cordova CLI and npm:

$ cordova plugin add cordova-plugin-googleplus --save --variable REVERSED_CLIENT_ID=myreversedclientid --variable WEB_APPLICATION_CLIENT_ID=mywebapplicationclientid
$ cordova prepare

Using the Cordova CLI to fetch the latest version from GitHub:

$ cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus --save --variable REVERSED_CLIENT_ID=myreversedclientid  --variable WEB_APPLICATION_CLIENT_ID=mywebapplicationclientid
$ cordova prepare

IMPORTANT:

  • Please note that myreversedclientid is a place holder for the reversed clientId you find in your iOS configuration file. Do not surround this value with quotes. (iOS only Applications)

  • If you are building a hybrid application (iOS and Android), or an Android application, you have to replace myreversedclientid with the reverse value of Client ID in your Release credential generated on step 3, on Google Developer's Console, this will be: "com.googleusercontent.apps.uniqueId", without quotes. Example: '123-abc123.apps.googleusercontent.com' becomes 'com.googleusercontent.apps.123-abc123'.

  • myreversedclientid is a place holder for Oauth Client ID specifically generated for web application in your Google Developer's Console.

GooglePlus.js is brought in automatically. There is no need to change or add anything in your html.

5. Installation (PhoneGap Build)

Add this to your config.xml:

For the (stable) NPM Version:

<plugin name="cordova-plugin-googleplus" source="npm">
  <variable name="REVERSED_CLIENT_ID" value="myreversedclientid" />
  <variable name="WEB_APPLICATION_CLIENT_ID" value="mywebapplicationclientid" />
</plugin>

For the latest version from Git (not recommended):

<plugin spec="https://github.com/EddyVerbruggen/cordova-plugin-googleplus.git" source="git">
  <variable name="REVERSED_CLIENT_ID" value="myreversedclientid" />
  <variable name="WEB_APPLICATION_CLIENT_ID" value="mywebapplicationclientid" />
<plugin>

6. Installation (iOS and Cocoapods)

This plugin use the CocoaPods dependency manager in order to satisfy the iOS Google SignIn SDK library dependencies.

Therefore please make sure you have Cocoapods installed in your iOS build environment - setup instructions can be found here. Also make sure your local Cocoapods repo is up-to-date by running pod repo update.

If building your project in Xcode, you need to open YourProject.xcworkspace (not YourProject.xcodeproj) so both your Cordova app project and the Pods project will be loaded into Xcode.

You can list the pod dependencies in your Cordova iOS project by installing cocoapods-dependencies:

sudo gem install cocoapods-dependencies
cd platforms/ios/
pod dependencies

7. Usage

Check the demo app to get you going quickly, or hurt yourself and follow these steps.

Note that none of these methods should be called before deviceready has fired.

Example:

document.addEventListener('deviceready', deviceReady, false);

function deviceReady() {
    //I get called when everything's ready for the plugin to be called!
    console.log('Device is ready!');
    window.plugins.googleplus.trySilentLogin(...);
}

isAvailable

3/31/16: This method is no longer required to be checked first. It is kept for code orthoganality.

Login

The login function walks the user through the Google Auth process. All parameters are optional, however there are a few caveats.

To get an idToken on Android, you must pass in your webClientId (a frequent mistake is to supply Android Client ID). On iOS, the idToken is included in the sign in result by default.

To get a serverAuthCode, you must pass in your webClientId and set offline to true. If offline is true, but no webClientId is provided, the serverAuthCode will NOT be requested.

The default scopes requested are profile and email (always requested). To request other scopes, add them as a space-separated list to the scopes parameter. They will be requested exactly as passed in. Refer to the Google Scopes documentation for info on valid scopes that can be requested. For example, 'scope': 'https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/tasks'.

Naturally, in order to use any additional scopes or APIs, they will need to be activated in your project Developer's Console.

Usage
window.plugins.googleplus.login(
    {
      'scopes': '... ', // optional, space-separated list of scopes, If not included or empty, defaults to `profile` and `email`.
      'webClientId': 'client id of the web app/server side', // optional clientId of your Web application from Credentials settings of your project - On Android, this MUST be included to get an idToken. On iOS, it is not required.
      'offline': true // optional, but requires the webClientId - if set to true the plugin will also return a serverAuthCode, which can be used to grant offline access to a non-Google server
    },
    function (obj) {
      alert(JSON.stringify(obj)); // do something useful instead of alerting
    },
    function (msg) {
      alert('error: ' + msg);
    }
);

The success callback (second argument) gets a JSON object with the following contents, with example data of my Google account:

 obj.email          // '[email protected]'
 obj.userId         // user id
 obj.displayName    // 'Eddy Verbruggen'
 obj.familyName     // 'Verbruggen'
 obj.givenName      // 'Eddy'
 obj.imageUrl       // 'http://link-to-my-profilepic.google.com'
 obj.idToken        // idToken that can be exchanged to verify user identity.
 obj.serverAuthCode // Auth code that can be exchanged for an access token and refresh token for offline access
 obj.accessToken    // OAuth2 access token

Additional user information is available by use case. Add the scopes needed to the scopes option then return the info to the result object being created in the handleSignInResult and didSignInForUser functions on Android and iOS, respectively.

On Android, the error callback (third argument) receives an error status code if authentication was not successful. A description of those status codes can be found on Google's android developer website at GoogleSignInStatusCodes.

On iOS, the error callback will include an NSError localizedDescription.

Try silent login

You can call trySilentLogin to check if they're already signed in to the app and sign them in silently if they are.

If it succeeds you will get the same object as the login function gets, but if it fails it will not show the authentication dialog to the user.

Calling trySilentLogin is done the same as login, except for the function name.

window.plugins.googleplus.trySilentLogin(
    {
      'scopes': '... ', // optional - space-separated list of scopes, If not included or empty, defaults to `profile` and `email`.
      'webClientId': 'client id of the web app/server side', // optional - clientId of your Web application from Credentials settings of your project - On Android, this MUST be included to get an idToken. On iOS, it is not required.
      'offline': true, // Optional, but requires the webClientId - if set to true the plugin will also return a serverAuthCode, which can be used to grant offline access to a non-Google server
    },
    function (obj) {
      alert(JSON.stringify(obj)); // do something useful instead of alerting
    },
    function (msg) {
      alert('error: ' + msg);
    }
);

It is strongly recommended that trySilentLogin is implemented with the same options as login, to avoid any potential complications.

logout

This will clear the OAuth2 token.

window.plugins.googleplus.logout(
    function (msg) {
      alert(msg); // do something useful instead of alerting
    }
);

disconnect

This will clear the OAuth2 token, forget which account was used to login, and disconnect that account from the app. This will require the user to allow the app access again next time they sign in. Be aware that this effect is not always instantaneous. It can take time to completely disconnect.

window.plugins.googleplus.disconnect(
    function (msg) {
      alert(msg); // do something useful instead of alerting
    }
);

8. Exchanging the idToken

Google Documentation for Authenticating with a Backend Server

As the above articles mention, the idToken can be exchanged for user information to confirm the users identity.

Note: Google does not want user identity data sent directly to a server. The idToken is their preferred method to send that data securely and safely, as it must be verified through their servers in order to unpack.

This has several uses. On the client-side, it can be a way to get doubly confirm the user identity, or it can be used to get details such as the email host domain. The server-side is where the idToken really hits its stride. It is an easy way to confirm the users identity before allowing them access to that servers resources or before exchanging the serverAuthCode for an access and refresh token (see the next section).

If your server-side only needs identity, and not additional account access, this is a secure and simple way to supply that information.

9. Exchanging the serverAuthCode

Google Documentation for Enabling Server-Side Access

As the above articles mention, the serverAuthCode is an item that can be exchanged for an access and refresh token. Unlike the idToken, this allows the server-side to have direct access to the users Google account.

Only in the initial login request serverAuthCode will be returned. If you wish to receive the token a second time, you can by using logout first.

You have a couple options when it comes to this exchange: you can use the Google REST Apis to get those in the hybrid app itself or you can send the code to your backend server to be exchanged there, using whatever method necessary (Google provides examples for Java, Python, and JS/HTTP).

As stated before, this plugin is all about user authentication and identity, so any use of the user's account beyond that needs to be implemented per use case, per application.

10. Troubleshooting

  • Q: I can't get authentication to work on Android. And why is there no ANDROID API KEY?

  • A: On Android you need to execute the keytool steps, see the installation instructions for details.

  • Q: After following the keytool steps, I still can't get authentication to work on Android. I'm having a "10 error"!!!

  • A: You need to get the SHA 1 cert from your apk file. Run: keytool -list -printcert -jarfile <your apk> and copy the SHA 1 to your Android Client ID on Google Console.

  • Q: OMG $@#*! the Android build is failing

  • A: You need to have Android Support Repository and Android Support Library installed in the Android SDK manager. Make sure you're using a fairly up to date version of those.

  • Q: Why isn't this working on my Android Emulator???

  • A: Make sure you are using a Virtual Device running with a Google APIs target and/or a Google APIs CPU!

  • Q: I'm getting Error 10, what do I do?

  • A: This is likely caused by cordova not using the keystore you want to use (e.g. because you generated your own). Please check https://cordova.apache.org/docs/en/latest/guide/platforms/android/#signing-an-app to read how to do this. Some have reported that you need to run cordova clean before running the build to resolve error 10.

  • Q: I'm getting Error 16, what do I do?

  • A: This is always a problem because the signature (or fingerprint) of your android app when signed is not added to the google console (or firebase) OAuth whitelist. Please double check if you did everything required for this. See the mini-guide below.

Error 16 & app signing mini-guide

First, make sure you fully read and understand the guide on App Signing from the android documentation!

After/while reading that, double check if you did all steps 1-4 below correctly:

1. Make a keystore

In order to sign your app (on dev or publish) you will need to make a local keystore and key with Android Studio or via terminal. Google has a feature called "Google Play App Signing" where they will keep the key on their server and sign your app for you, but if you use this feature or not, you will need a local keystore and key either way.

  • If you do not use "Google Play App Signing" → go to 3A
  • If you do use "Google Play App Signing" → go to 3B

2A. Without Google Play App Signing

Your local keystore and key will be your official app signing key.

You will need to whitelist the following key fingerprints (in SHA1 format) in Google OAuth settings:

  • android default debug.keystore key
  • your own created keystore with its key (for App Signing)

2B. With Google Play App Signing enabled

Your local keystore and key will be your "Upload key" and another key for official "App Signing key" is created and managed by Google.

You need to whitelist the following key fingerprints (in SHA1 format) in Google Oauth settings:

  • android default debug.keystore key
  • your own created keystore with its key (for Uploading)
  • google's App Signing key

3. Get key fingerprints

Get the above keys' fingerprints (in SHA1 format) to be able to whitelist them.

A. Debug key

For the android default debug.keystore do:

keytool -exportcert -keystore /Users/myusername/.android/debug.keystore  -list -v

You will see the SHA1 fingerprint for the debug key in terminal. Copy that.

B. App signing or Upload key

For the own created keystore with key (either for 2A or 2B) do:

keytool -exportcert -keystore /path/to/your/key/yourKeystoreFile.keystore  -list -v

You will see the SHA1 fingerprint for the debug key in terminal. Copy that.

C. Google's App signing key

Only when Google Play App Signing is enabled (for 2B). You can find the key Google will use to sign your builds in the Google Play Console.

Requirement: You need to have finished the basic info on your android app and then you need to upload a signed APK for internal testing. Once this is uploaded you will be able to access the following menu:

Go to Release Management > App sigining. There you will see

  • "App signing certificate" and SHA-1 fingerprint
  • "Upload certificate" and SHA-1 fingerprint

The "Upload" one is (and should be) the same as key B. above. And the "App signing certificate" is the key that Google will use. Copy this one.

4. Whitelist the key fingerprints

Again we have 2 options to whitelist them. Projects that use only the Google Cloud Platform or projects that use Firebase.

A. Google Cloud Platform projects

(In case you also use Firebase, you can skip this step)

  1. Go to API & Services > credentials
  2. Create credentials > OAuth client ID
  3. choose "android" and insert your SHA1
  4. Repeat this for all keys (2 or 3)

B. Firebase projects

  1. Go to the console > Projects settings
  2. Select your Android app at the bottom. (if you don't have any, add an android app, you can ignore the whole tutorial they give you, it's irrelevant for Cordova apps)
  3. Add the finger prints to the "SHA certificate fingerprints" section.
  4. Double check your Google Cloud console: API & Services > credentials and see that Firebase has added these automatically at the bottom under "OAuth 2.0 client IDs"

cordova-plugin-googleplus's People

Contributors

aaronjensen avatar abhishekporwal avatar abrahamh08 avatar adriano-di-giovanni avatar anu2g avatar armanio avatar artlogic avatar benjamn avatar bramzor avatar cleventy avatar danielochoa avatar eddyverbruggen avatar gvhuyssteen avatar habibillah avatar hllorens avatar jacqueskang avatar leogoesger avatar maksymilian-majer avatar maxrevilo avatar mesqueeb avatar mike-nelson avatar pampul avatar peterpeterparker avatar pghoratiu avatar phw avatar ryaa avatar steaks avatar virtser avatar wouterbin avatar zphingphong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-googleplus's Issues

USER CANCELLED

I installed the plugin on a clean cordova 3.6 project, but when i try to login an error occurred saying "USER CANCELLED".

Enable server-side API access for app

Hi,
Can you please suggest if I can use the same plugin to request a one-time authorization code.
Basically I need one-time authorization code , as I want server to be able to make Google API calls on behalf of users or while they are offline.

Current plugin is working successfully as client side implementation. It would be great if you could expose that API in GooglePlus.js

Thanks,
Sagar

Change password on your Google account via browser.

On Google+ App, when you already listed your account and use it as your login authentication it should work just fine and redirects back to the client(your app) with the data but when you try to change the password on your browser and use the same account again to login back to your client(your app), what happened here is that it redirects back to the client(your app) but doing nothing..

Try checking the Google+ auth again then the listed account is gone on the list so you need to add your account again to use this as your login authentication.

Is there something to do with the plugin's part or maybe Google+ app is not telling us that the account used has already changed the password and need to re-authenticate back again?

User might think that the app is broken and doing nothing they might have no idea if they need to re-authenticate back using new password.

Only get email

I test the demo, with my google+ account, but I'm only get my email. Why?
It may be for the settings of my acount?

Google+ login using web browser is rejected on the App Store.

Reasons from App Strore:
We found the following issues with the user interface of your app:

The app opens a web page in mobile Safari for logging into Google+, then returns the user to the app. The user should be able to log in without opening Safari first.


The plugin is fine and working but didn't passed app standard using a web page. If user already installed the Google+ app then the authentication is on the app which is good otherwise it will open a web browser to do the authentication. To solve this one is we need to wrap it inside inappbrowser.

When following instructions in README.md GooglePlus.* does not get installed

When doing:

$ cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus.git
$ cordova prepare

GooglePlus.m and GooglePlus.h does not get copied to
platforms/ios/<project>/Plugins/nl.x-services.plugins.googleplus/
and compilation fails.

I resolved the issue by copying the files there manuallly. Am I missing something, or is this a bug somewhere? I'm using ionic cli v1.2.8 and cordova 3.6.3

Is it possible to pass scopes?

Hello!
Thank you for the plugin.. it looks really great!

I have a question though.. is it possible to me to specify a list of scopes I'd like to request?

Thank you in advance

Error: User Cancelled

Why does not the android login require any api key?

And please do the docs better. It is too simple and does not work.!!!

problem with login

hello
i am using phonegap 4.1.2 version
and cordova 4.3.0 version

i'm installed the plugin and create google plus key by following the tutorial.
i got available - true
BUT when i'm trying to login i got :
error: failed to retrieve
token: unknown

why it happen ?
thanks a lof

Phonegap Build Server Error on Plugin Include

Hello,

When <gap:plugin name="nl.x-services.plugins.googleplus" version="1.0.7" /> is added to the project with or without the version attribute Phonegap Build fails with the attached screen shot.

http://i.imgur.com/KylmTw8.jpg

Works fine when I remove it, and the other plugins are working fine as well.

Is this not compatible with Phonegap Build?

404 error whe installing

cordova plugin add nl.x-services.plugins.googleplus

gives me 404 error. how I can install it?

Client Id error iun Android

Hello, i was trying this plugin and i have an issue with the client id. When i run the app and try to connect i get the error: "gms.StatusHelper Status from wire: INVALID_CLIENT_ID status: null".

I have been trying to find the file index.js or where to specify the client id but it has been imposible to me.

I am also confuse about the parameter iOSApiKey, I read that it should be use just in Android, is ir right?

what package to insert?

i m having a problem the mentioned befor
"failed to retrieve token: unknown"

but i thing the problem is in the inserted package
what should it be ?

thanks

How to install without using the cordova command line tool?

What are the steps to to install the plugin as suggested by the readme?

"Installing this plugin directly from Cordova Registry results in Xcode using a broken GoogleOpenSource.framework and GooglePlus.framework, this is because the current publish procedure to NPM breaks symlinks CB-6092.Please install the plugin through a locally cloned copy or re-add the frameworks to Xcode after installation."

idToken doesn't exist in the response

Making the login call gives me the following response
{
"imageUrl": "https://lh5.googleusercontent.com/-...,
"email": "[email protected]",
"oauthToken": "ya29.SQEasqZc9AGIYldS0OM1XBNRJATSVEZ0jCbOl_7kS68OTc0Q9-_AZTT_lsmyER-8vEr9VByma_Q2Bw",
"userId": "1046196110041037865",
"familyName": "Smith",
"gender": "male",
"givenName": "John",
"displayName": "John Smith"
}

Here there is no idToken as mentioned in the documents.
I want to use the idToken and the accessToken on the server side to reverify and retrieve the user data on the server side.
What might be the problem here?

Does this plugin use a non-standard or old Android support jar file?

I'm having a dependency issue in my Phonegap project, and it seems to be because of this plugin using an old version of the Android support jar. This issue is described in #20, but I can't use that fix as I don't have the luxury of modifying my builds - we're using Phonegap Build. As a summary, there's a dependency discrepancy with com.phonegap.plugins.facebookconnect. Project builds fine if I use com.phonegap.plugins.facebookconnect v0.4.0, but if I use the latest, I get the dependency issue.

Looking at the code cordova-plugin-googleplus, this line of code at plugin.xml ln 32 seems suspect:

<dependency id="[email protected]"
    url="https://github.com/MobileChromeApps/cordova-plugin-android-support-v4" />

In comparison, facebookconnect adds it as part of the gradle build in platforms/android/FacebookLib/build.gradle:

dependencies {
    compile 'com.android.support:support-v4:[20,21)'
    compile 'com.parse.bolts:bolts-android:1.1.2'
}

I realise these are pretty different approaches. I'm not experienced with Android builds so can't comment knowledgeably - which repo is using the standard approach, and which repo needs to adjust its code to match?

~/adt-bundle-linux/sdk/tools/ant/build.xml:577: Jar mismatch! Fix your dependencies.

I added the plugin, and now I get this error : ~/adt-bundle-linux/sdk/tools/ant/build.xml:577: Jar mismatch! Fix your dependencies.

[dependency] Found 2 versions of android-support-v4.jar in the dependency list,
[dependency] but not all the versions are identical (check is based on SHA-1 only at this time).
[dependency] All versions of the libraries must be the same at this time.
[dependency] Versions found are:
[dependency] Path: /home/siddharth/appTest/Madzz/ui/platforms/android/com.phonegap.plugins.facebookconnect/FacebookLib/libs/android-support-v4.jar
[dependency]    Length: 758727
[dependency]    SHA-1: efec67655f6db90757faa37201efcee2a9ec3507
[dependency] Path: /home/siddharth/appTest/Madzz/ui/platforms/android/libs/android-support-v4.jar
[dependency]    Length: 987314
[dependency]    SHA-1: 9b6a9a9078af571732159b904ad423b03b7cc786

BUILD FAILED
/home/siddharth/Downloads/adt-bundle-linux/sdk/tools/ant/build.xml:577: Jar mismatch! Fix your dependencies

Total time: 1 second

/home/siddharth/appTest/Madzz/ui/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: ant with args: debug,-f,/home/siddharth/appTest/Madzz/ui/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /home/siddharth/appTest/Madzz/ui/platforms/android/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)

Please have a look at this

JAR from another plugin is interrupting

cordova-plugin-googleplus integration with Intel XDK

Hi,

I followed the instructions to setup cordova-plugins.
I have added the git from Intel XDK 3rd party plugins.
As per Intel XDK these 3rd party plugins will not work in Emulator and In App Preview.

After doing the google workflow as u mentioned. I used your code and placed it in my function
which is being called on a event.

all event handlers are initialized/added after onload/deviceready.

I do not see any popup opening while i compile my code using android cross wallk.
after build options are failing.

function init()
{

    intel.xdk.device.hideSplashScreen();
    alert("Device Ready");
    log("Hiding Splash Screen");

     //Add Event Listener For Login Pages And Registration Pages

    document.getElementById("googleConnect").addEventListener("click",function()
    {
       oAuthGoogle();
    });



    document.getElementById("googleSign").addEventListener("click",function()
    {
     oAuthGoogle();
    });

window.addEventListener("intel.xdk.device.ready",init);

//Globally Object Available
log = console.log.bind(console);
error = console.error.bind(console);
globalContext ={};

function oAuthGoogle()
{

window.plugins.googleplus.login(
{

},
function (obj) 
{
  alert(JSON.stringify(obj)); // do something useful instead of alerting
},
function (msg) 
{
  alert('error: ' + msg);
}

);

}

Please help me out as i need to integrate this.

Looking forward to your response.

Failed to retrieve token: unknown

Hi,

after clicking on google+ login button authentication window is loading and after accepting iam getting the follwoing error

Failed to retrieve token:Unknown

redirect url not handled when redirected from Google+ app on iOS

Hi,

In the AppDelegate entry point (IdentityUrlHandling):

(BOOL)identity_application: (UIApplication *)application
                 openURL: (NSURL *)url
       sourceApplication: (NSString *)sourceApplication
              annotation: (id)annotation

the url does not contain "oauth2callback" when redirected from the Google+ app. It only contains this string when redirected from Safari. Locally I fixed this as follows inside the AppDelegate entry point:

GooglePlus* gp = (GooglePlus*)[[self.viewController pluginObjects] objectForKey:@"GooglePlus"];

if ([gp isSigningIn]) {
    return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];
} else {
    // call super
    return [self identity_application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}

In the GooglePlus class I maintain a isSigningIn state.

Kind regards,

-- Freddy

Google asks for permissions on subsequent logins

Each time a single user logs into our app, they get asked if they want to give our app the list of requested permissions. This is different behaviour in comparison to Facebook, where permissions are only asked the first time.

Is this behaviour the unchangeable Google behaviour, or can permissions simply be asked for just the first time?

Cannot open the page the URL is invalid

Hi guys,
I'm trying to install your plugin in my app.

However I have an issue before the callback on my iOS (iPhone6) simulator.
The safari page opens well, i'm entering my creds but after the app authorization screen it says "cannot open the page url invalid"

Do you know why ?

Thanks

inernal error problem

Hi, i have a smal problem.
if is start my app from eclipse to my phone the google plus login works 100% all the time.
but if i upload my exportet apk to google dev console and than install on my device from the playstore
i get the interlal error. whats the problem? is they sha1 key chainging by uploading the apk?

Android does not prompt again for email to use for login

The account logout (so it asks me which email I want to use) doesn't actually logout. I tried both logout and disconnect but neither results in a reprompt for the email I want to use when I try to login again.

window.plugins.googleplus.logout(
    function (msg) {
      console.log(msg);
    }
);
window.plugins.googleplus.disconnect(
    function (msg) {
        console.log('disconnected account too.', msg);
    }
);

I have two email accounts on my phone, and need to actually uninstall the app, then reinstall, in order to get the email prompt to come back up.

Service not available / Android

Hi there, just downloaded your example, installed the plugin and tested it on IOS and Android.

On Ios works great, but on Android I always get Error: Service not available.
Other thing is that I didn't found where do I config my Client Id for Android.
Thank you for your help

Cordova version: 4.0
SDK: 19

Ask new oauthToken each time

Dear,
I have an android chat application where the user can register/login to the application via google plus.
So on my server I authenticate the _oauthToken_ with google, then get _refreshToken_ and store it.
The problem is:
-User try to register: OK, send oauthToken to server,authenticated with google plus,
-User decline registration
-user retry to register:OK, , send oauthToken to server,not authenticated with google plus("invalid grant"), because i am trying to authenticate the same _oauthToken.
Does there are a way to get new _oauthToken
every time.
Thank you.

Plugin doesn't appear to be in Cordova registry.

I am attempting to add the plugin using Visual Studio 2015 with the Tools for Apache Cordova. I can initially add the plugin fine, but when I go to build I see plugman is trying to retrieve the plugin from the registry and it cannot be found. Has it maybe not been published?

Here's the relevant part of the build log:

Calling plugman.fetch on plugin "[email protected]"
  Fetching plugin "[email protected]" via plugin registry
  npm http GET http://registry.cordova.io/org.apache.cordova.camera/0.3.2
  npm http 200 http://registry.cordova.io/org.apache.cordova.camera/0.3.2
  npm http GET http://cordova.iriscouch.com/registry/_design/app/_rewrite/org.apache.cordova.camera/-/org.apache.cordova.camera-0.3.2.tgz
  npm http 200 http://cordova.iriscouch.com/registry/_design/app/_rewrite/org.apache.cordova.camera/-/org.apache.cordova.camera-0.3.2.tgz
  Copying plugin "C:\Users\Bryan\.plugman\cache\org.apache.cordova.camera\0.3.2\package" => "C:\Users\Bryan\Documents\Visual Studio 2015\Projects\BlankCordovaApp1\BlankCordovaApp1\bld\Debug\plugins\org.apache.cordova.camera"
  ------ Adding plugin: [email protected]
  Calling plugman.fetch on plugin "[email protected]"
  Fetching plugin "[email protected]" via plugin registry
  npm http GET http://registry.cordova.io/org.apache.cordova.inappbrowser/0.5.2
  npm http 200 http://registry.cordova.io/org.apache.cordova.inappbrowser/0.5.2
  npm http GET http://cordova.iriscouch.com/registry/_design/app/_rewrite/org.apache.cordova.inappbrowser/-/org.apache.cordova.inappbrowser-0.5.2.tgz
  npm http 200 http://cordova.iriscouch.com/registry/_design/app/_rewrite/org.apache.cordova.inappbrowser/-/org.apache.cordova.inappbrowser-0.5.2.tgz
  Copying plugin "C:\Users\Bryan\.plugman\cache\org.apache.cordova.inappbrowser\0.5.2\package" => "C:\Users\Bryan\Documents\Visual Studio 2015\Projects\BlankCordovaApp1\BlankCordovaApp1\bld\Debug\plugins\org.apache.cordova.inappbrowser"
  ------ Adding plugin: [email protected]
  Calling plugman.fetch on plugin "[email protected]"
  Fetching plugin "[email protected]" via plugin registry
  npm http GET http://registry.cordova.io/nl.x-services.plugins.googleplus/1.0.7
  npmError: 404 Not Found: nl.x-services.plugins.googleplus

If its just case a case of publishing the plugin, would you mind? Would be a big help!

Thanks!

Ionic Error

I am using this plugin in Ionic using ng-Cordova
But it gives me this error:
Unknown provider: $cordovaGooglePlusProvider <- $cordovaGooglePlus

I have included it like this in my controller:
app.controller('SignInCtrl', function($rootScope, $scope, $state, $filter, $ionicPopup, $localStorage, $cordovaOauth, $ionicSideMenuDelegate, $cordovaPush, $cordovaDialogs, $cordovaMedia, $cordovaToast, $cordovaFacebook, $cordovaGooglePlus , HawkUser,Consumer,Subscription,UserDevice,API,ENV)

User-cancelled login on iOS - Neither the success nor error callbacks are called

  1. User initiates login.
  2. User is sent to the Google+ login page (browser).
  3. User taps the Cancel button.
  4. User returns to app splash screen, and neither the success nor error JavaScript callbacks are called.

This patch fixes the problem for me (I just changed the old writeJavascript: method to returning to JS with the new sendPluginResult:callbackId method).

===================================================================
--- GooglePlus.m    (revision 17927)
+++ GooglePlus.m    (working copy)
@@ -41,7 +41,7 @@
   // trySilentAuthentication doesn't call delegate when it fails, so handle it here
   if (![[self getGooglePlusSignInObject:command] trySilentAuthentication]) {
     CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no valid token"];
-    [self writeJavascript:[pluginResult toErrorCallbackString:command.callbackId]];
+    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
   }
 }

@@ -51,7 +51,7 @@
   NSString* apiKey = [options objectForKey:@"iOSApiKey"];
   if (apiKey == nil) {
     CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"iOSApiKey not set"];
-    [self writeJavascript:[pluginResult toErrorCallbackString:_callbackId]];
+    [self.commandDelegate sendPluginResult:pluginResult callbackId:_callbackId];
     return nil;
   }

@@ -69,13 +69,13 @@
 - (void) logout:(CDVInvokedUrlCommand*)command {
   [[GPPSignIn sharedInstance] signOut];
   CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"logged out"];
-  [self writeJavascript:[pluginResult toSuccessCallbackString:command.callbackId]];
+  [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
 }

 - (void) disconnect:(CDVInvokedUrlCommand*)command {
   [[GPPSignIn sharedInstance] disconnect];
   CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"disconnected"];
-  [self writeJavascript:[pluginResult toSuccessCallbackString:command.callbackId]];
+  [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
 }

 - (void) share_unused:(CDVInvokedUrlCommand*)command {
@@ -87,7 +87,7 @@
                    error:(NSError *)error {
   if (error) {
     CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.localizedDescription];
-    [self writeJavascript:[pluginResult toErrorCallbackString:_callbackId]];
+    [self.commandDelegate sendPluginResult:pluginResult callbackId:_callbackId];
   } else {
     NSString *email = [GPPSignIn sharedInstance].userEmail;
     NSString *token = [GPPSignIn sharedInstance].idToken;
@@ -116,7 +116,8 @@
                  };
     }
     CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
-    [self writeJavascript:[pluginResult toSuccessCallbackString:_callbackId]];
+    [self.commandDelegate sendPluginResult:pluginResult callbackId:_callbackId];
+
   }
 }

Older plugin version available for PhoneGap Build?

Hi,

I'm trying to create a PhoneGap app that uses this plugin and the Facebook Connect plugin. Unfortunately I get a "jar mismatch" error on PhoneGap Build when both plugins are included. Apparently the Google Plus plugin uses version 21 of android-support-v4.jar while the other plugin uses version 20. Is it possible to make version 1.0.5 of the Google Plus plugin available for PhoneGap Build again?

On Android Error is thrown : FAILED TO RETRIEVE TOKEN

Hi,

while performing google sign in i get an error
"FAILED TO RETRIEVE TOKEN: UNKNOWN"

Generated SHA1 like below
keytool -genkey -v -keystore test.keystore -alias test -keyalg RSA -validity 10000

keytool -export -alias test -keystore C:\keytools\test.keystore -list -v

Afterwards got and copied an SHA1 with deep linking enabled
pasted the package="com.test.app" from androidmanifest.xml into package name

I should be able to retrieve the token and an success object. buts its not happening.

my code below is

function googleAuth()
{

window.plugins.googleplus.login(
{
/'iOSApiKey': '1234567890-abcdefghijklm74bfw.apps.googleusercontent.com'/
},
function (obj) {
out("Google+ Login : ");
out(JSON.stringify(obj)); // do something useful instead of alerting
},
function (msg) {
out('Google+ Error : ' + msg);
window.plugins.googleplus.logout(
function (msg)
{
out("Logging Off Google+");
out(msg); // do something useful instead of alerting
});

  //Dicconnect
  window.plugins.googleplus.disconnect(
function (msg) {
  out("Disconnecting Google+");
  out(msg); // do something useful instead of alerting
});

}

);

where out can be replaced with console.log

Please help. Please suggest where i am getting it wrong

"trySilentLogin" still not work after use "window.plugins.googleplus.login" (only in Android)

I am using Android 4.4.2
when I am not already use "window.plugins.googleplus.login",if I use "trySilentLogin",it will show the err callback,"no value token"
but..
when I am already use "window.plugins.googleplus.login" and got many information about JSON.stringify(obj)
this time if I use "trySilentLogin" again,it will show nothing (no any response),still not trigger the success callback

my code just as same as yours and use your 1.0.7 version on PGB,1.0.8 version not try yet on "plugins.cordova.io"

PS
so that will cause only the first time login can got the full JSON.stringify(obj),after it,it will no way to trigger it again,otherwise disconnect and login again

An internal error occurred.

Everytime I click on "Login with Google+" in Android, I am getting an error message "An internal error occurred."

Signed Cert SHA Key for debug apk

Probably a very basic question and I am missing something very trivial.
When you use cordova build android or cordova run android it spits out a normal apk.
Of course I would like to avoid the manually signing of the debug packages. How did you guys get the sha keys for google api developers console for the debug apk's?
Thanks in advance, Frank

"login" and "trySilentLogin" only can trigger once after "login success"

hi @EddyVerbruggen

when I use

window.plugins.googleplus.login

it will fully success in Android and iOS
and got many information about JSON.stringify(obj)

well...after this
when I use these method again

window.plugins.googleplus.login
OR
window.plugins.googleplus.trySilentLogin

[in iOS]
it will still got many information about JSON.stringify(obj) again

but...
[in Android 4.4.2]
it will no any response anymore

Docs for android

Hi Eddy:

The idea of this plugin is neat and makes google+ sign up much easier.
I went through this readme and example code to make this magic to my android, but didn't luck.
And, i dont have much idea to start debugging for my app because the android docs is not quite complete yet ~ Base on your screenshot with android, i believe you made it. Could you share me your android example code ?

Thanks man

Subsequent calls are blocking

When using the calls from the plugin with Cordova 4.0.0, the first call succeeds as expected, but any subsequent calls are blocking (never returning).

LogCat is showing the following entries:
12-30 09:11:48.925: I/System.out(22771): {"iOSApiKey":"XXX.apps.googleusercontent.com"}

Whenever I call the plugin function, e.g. trySilentLogin, it always only works the first time. Then it just is not returning anymore with every call.

What am I doing wrong?

Android parameter for api Key

I am using for both iphone and android.Its working smoothly in IOS but not in android. I am getting "user cancelled" error everytimes. What will be api key parameter for android instead of "iOSApiKey".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.