{"_id":"@cubaka14/capacitor-google-auth","_rev":"2-5ec3873f1eba3f5eebc3bc0ee2835ba2","name":"@cubaka14/capacitor-google-auth","dist-tags":{"latest":"3.4.3"},"versions":{"3.4.1":{"name":"@cubaka14/capacitor-google-auth","version":"3.4.1","description":"Google Auth plugin for capacitor.","main":"dist/esm/index.js","types":"dist/esm/index.d.ts","scripts":{"build":"npm run clean && tsc","clean":"rm -rf ./dist","watch":"tsc --watch","prepublishOnly":"npm run build","prepare":"tsc","test":"echo \"no test specified\"","docgen":"docgen --api GoogleAuthPlugin --output-readme README.md"},"author":{"name":"CodetrixStudio"},"license":"MIT","devDependencies":{"@capacitor/android":"^5.0.4","@capacitor/cli":"^5.0.4","@capacitor/core":"^5.0.4","@capacitor/docgen":"^0.2.1","@capacitor/ios":"^5.0.4","@ionic/prettier-config":"^2.0.0","@types/gapi":"0.0.42","@types/gapi.auth2":"0.0.56","prettier":"^2.7.1","typescript":"^4.7.4"},"peerDependencies":{"@capacitor/core":"^5.0.0"},"keywords":["capacitor","plugin","native","google","auth","firebase","angular","vue","react","ionic"],"capacitor":{"ios":{"src":"ios"},"android":{"src":"android"}},"repository":{"type":"git","url":"git+https://github.com/CodetrixStudio/CapacitorGoogleAuth.git"},"bugs":{"url":"https://github.com/CodetrixStudio/CapacitorGoogleAuth/issues"},"prettier":"@ionic/prettier-config","gitHead":"7deb0e157768ab927adcab3dae554d03f173aa7b","homepage":"https://github.com/CodetrixStudio/CapacitorGoogleAuth#readme","_id":"@cubaka14/capacitor-google-auth@3.4.1","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-v0HxA+nPcb99srmkHO2mGi9/bkNLaWmbASJC9NA0CraPX3OYol9GJk4nfNl7O5sJJ7j4E8kH6yr3baEdvR/COQ==","shasum":"62f77581be9014ddfd61091e2259580d84698966","tarball":"https://registry.npmjs.org/@cubaka14/capacitor-google-auth/-/capacitor-google-auth-3.4.1.tgz","fileCount":41,"unpackedSize":160030,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDGKh1IwFyE7dnPPaInfK4MzntCshI5/b0OEeH+VgxVSwIhALicvniviWK2rTshev6AyqhDsb5fZbIK2gv3JKs5U9TN"}]},"_npmUser":{"name":"cubaka14","email":"antic.cubaka@gmail.com"},"directories":{},"maintainers":[{"name":"cubaka14","email":"antic.cubaka@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/capacitor-google-auth_3.4.1_1713573992271_0.6183798203298008"},"_hasShrinkwrap":false},"3.4.2":{"name":"@cubaka14/capacitor-google-auth","version":"3.4.2","description":"Google Auth plugin for capacitor.","main":"dist/esm/index.js","types":"dist/esm/index.d.ts","scripts":{"build":"npm run clean && tsc","clean":"rm -rf ./dist","watch":"tsc --watch","prepublishOnly":"npm run build","prepare":"tsc","test":"echo \"no test specified\"","docgen":"docgen --api GoogleAuthPlugin --output-readme README.md"},"author":{"name":"CodetrixStudio"},"license":"MIT","devDependencies":{"@capacitor/android":"^5.0.4","@capacitor/cli":"^5.0.4","@capacitor/core":"^5.0.4","@capacitor/docgen":"^0.2.1","@capacitor/ios":"^5.0.4","@ionic/prettier-config":"^2.0.0","@types/gapi":"0.0.42","@types/gapi.auth2":"0.0.56","prettier":"^2.7.1","typescript":"^4.7.4"},"peerDependencies":{"@capacitor/core":"^5.0.0"},"keywords":["capacitor","plugin","native","google","auth","firebase","angular","vue","react","ionic"],"capacitor":{"ios":{"src":"ios"},"android":{"src":"android"}},"repository":{"type":"git","url":"git+https://github.com/CodetrixStudio/CapacitorGoogleAuth.git"},"bugs":{"url":"https://github.com/CodetrixStudio/CapacitorGoogleAuth/issues"},"prettier":"@ionic/prettier-config","gitHead":"e6812b6dcf57c12ba381f09a621b4be5f796bedb","homepage":"https://github.com/CodetrixStudio/CapacitorGoogleAuth#readme","_id":"@cubaka14/capacitor-google-auth@3.4.2","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-VbT1CaA6LQsEN/9kQChlHTqVkp24eHrm+DO62OCk07UrOGlsIzU83UooSYDj6Qu22FmInoY43HOWBB/aoDexGA==","shasum":"473281d62d86e9d3772a63f62671770164e1d785","tarball":"https://registry.npmjs.org/@cubaka14/capacitor-google-auth/-/capacitor-google-auth-3.4.2.tgz","fileCount":40,"unpackedSize":159429,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICN/9BMdK3n31ldSoG/fmrYHzkNNULwlvHizKudbpXiEAiEArDpWF66j9/VRyHSMmiyLNdMd2Yqq4wwFPj3YlPZTEBs="}]},"_npmUser":{"name":"cubaka14","email":"antic.cubaka@gmail.com"},"directories":{},"maintainers":[{"name":"cubaka14","email":"antic.cubaka@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/capacitor-google-auth_3.4.2_1713574608018_0.9086102731070491"},"_hasShrinkwrap":false},"3.4.3":{"name":"@cubaka14/capacitor-google-auth","version":"3.4.3","description":"Google Auth plugin for capacitor.","main":"dist/esm/index.js","types":"dist/esm/index.d.ts","scripts":{"build":"npm run clean && tsc","clean":"rm -rf ./dist","watch":"tsc --watch","prepublishOnly":"npm run build","prepare":"tsc","test":"echo \"no test specified\"","docgen":"docgen --api GoogleAuthPlugin --output-readme README.md"},"author":{"name":"CodetrixStudio"},"license":"MIT","devDependencies":{"@capacitor/android":"^5.0.4","@capacitor/cli":"^5.0.4","@capacitor/core":"^5.0.4","@capacitor/docgen":"^0.2.1","@capacitor/ios":"^5.0.4","@ionic/prettier-config":"^2.0.0","@types/gapi":"0.0.42","@types/gapi.auth2":"0.0.56","prettier":"^2.7.1","typescript":"^4.7.4"},"peerDependencies":{"@capacitor/core":"^5.0.0"},"keywords":["capacitor","plugin","native","google","auth","firebase","angular","vue","react","ionic"],"capacitor":{"ios":{"src":"ios"},"android":{"src":"android"}},"repository":{"type":"git","url":"git+https://github.com/CodetrixStudio/CapacitorGoogleAuth.git"},"bugs":{"url":"https://github.com/CodetrixStudio/CapacitorGoogleAuth/issues"},"prettier":"@ionic/prettier-config","gitHead":"aa76b51300408bebf6b09a73f192115d6d27914f","homepage":"https://github.com/CodetrixStudio/CapacitorGoogleAuth#readme","_id":"@cubaka14/capacitor-google-auth@3.4.3","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-/XHMji2E5G5nOdwxzdG0itXYXJwf+RLbqcZcFQt3vYzymK1gqPfZt0uSS19cYemrSyXzHf1bfz++z/IFGZ2fGg==","shasum":"a0700afe46390a28afe9e6e1ae0b64464b569b54","tarball":"https://registry.npmjs.org/@cubaka14/capacitor-google-auth/-/capacitor-google-auth-3.4.3.tgz","fileCount":41,"unpackedSize":160018,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDek6JdD4G+M/DBCrKUSTxdFh6yuqmcmGTunxBhU48srQIhAI0zM9aCgvVnxsT81VPe6X4+P32K7nEdmu3XS6hL7l9G"}]},"_npmUser":{"name":"cubaka14","email":"antic.cubaka@gmail.com"},"directories":{},"maintainers":[{"name":"cubaka14","email":"antic.cubaka@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/capacitor-google-auth_3.4.3_1713575250903_0.19315046247476686"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-20T00:46:32.178Z","3.4.1":"2024-04-20T00:46:32.446Z","modified":"2024-04-20T01:07:31.409Z","3.4.2":"2024-04-20T00:56:48.152Z","3.4.3":"2024-04-20T01:07:31.223Z"},"maintainers":[{"name":"cubaka14","email":"antic.cubaka@gmail.com"}],"description":"Google Auth plugin for capacitor.","homepage":"https://github.com/CodetrixStudio/CapacitorGoogleAuth#readme","keywords":["capacitor","plugin","native","google","auth","firebase","angular","vue","react","ionic"],"repository":{"type":"git","url":"git+https://github.com/CodetrixStudio/CapacitorGoogleAuth.git"},"author":{"name":"CodetrixStudio"},"bugs":{"url":"https://github.com/CodetrixStudio/CapacitorGoogleAuth/issues"},"license":"MIT","readme":"<h1 align=\"center\">CapacitorGoogleAuth</h1>\n<p align=\"center\"><strong><code>@codetrix-studio/capacitor-google-auth</code></strong></p>\n<p align=\"center\"><strong>CAPACITOR 5</strong></p>\n<p align=\"center\">\nCapacitor plugin for Google Auth.\n</p>\n<br>\n<p align=\"center\">\n<a href=\"https://www.npmjs.com/package/@codetrix-studio/capacitor-google-auth\"><img alt=\"npm\" src=\"https://img.shields.io/npm/v/@codetrix-studio/capacitor-google-auth\"></a> <a href=\"https://www.npmjs.com/package/@codetrix-studio/capacitor-google-auth\"><img alt=\"npm\" src=\"https://img.shields.io/npm/dt/@codetrix-studio/capacitor-google-auth\"></a> <a href=\"https://www.npmjs.com/package/@codetrix-studio/capacitor-google-auth\"><img alt=\"npm\" src=\"https://img.shields.io/npm/dw/@codetrix-studio/capacitor-google-auth\"></a> <a href=\"https://libraries.io/npm/@codetrix-studio%2Fcapacitor-google-auth\"><img alt=\"Dependents (via libraries.io)\" src=\"https://img.shields.io/librariesio/dependents/npm/@codetrix-studio/capacitor-google-auth\"></a> <a href=\"https://packagephobia.com/result?p=@codetrix-studio/capacitor-google-auth\"><img alt=\"install size\" src=\"https://packagephobia.com/badge?p=@codetrix-studio/capacitor-google-auth\"></a>\n</p>\n\n## Contributions\n\nPRs are welcome and much appreciated that keeps this plugin up to date with Capacitor and official Google Auth platform library feature parity.\n\nTry to follow good code practices. You can even help keeping the included demo updated.\n\nPRs for features that are not aligned with the official Google Auth library are discouraged.\n\n(We are beginner-friendly here)\n\n## Install\n\n#### 1. Install package\n\n```sh\nnpm i --save @codetrix-studio/capacitor-google-auth\n\n# pnpm \npnpm add @codetrix-studio/capacitor-google-auth\n\n# yarn \nyarn add @codetrix-studio/capacitor-google-auth\n```\n\n#### 2. Update capacitor deps\n\n```sh\nnpx cap update\n```\n\n## Updating\n\nIf need migrate to different Capacitor versions [see instruction for migrate plugin to new version](#migration-guide).\n\n## Usage\n\n### WEB\n\nRegister plugin and manually initialize\n\n```ts\nimport { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';\n\n// use hook after platform dom ready\nGoogleAuth.initialize({\n  clientId: 'CLIENT_ID.apps.googleusercontent.com',\n  scopes: ['profile', 'email'],\n  grantOfflineAccess: true,\n});\n```\n\nor if need use meta tags (Optional):\n\n```html\n<meta name=\"google-signin-client_id\" content=\"{your client id here}\" />\n<meta name=\"google-signin-scope\" content=\"profile email\" />\n```\n\n#### Options\n\n- `clientId` - The app's client ID, found and created in the Google Developers Console.\n- `scopes` – same as [Configure](#Configure) scopes\n- `grantOfflineAccess` – boolean, default `false`, Set if your application needs to refresh access tokens when the user is not present at the browser.\n\nUse it\n\n```ts\nGoogleAuth.signIn();\n```\n\n#### Angular\n\ninit hook\n\n```ts\n// app.component.ts\nconstructor() {\n  this.initializeApp();\n}\n\ninitializeApp() {\n  this.platform.ready().then(() => {\n    GoogleAuth.initialize()\n  })\n}\n```\n\nsign in function\n\n```ts\nasync googleSignIn() {\n  let googleUser = await GoogleAuth.signIn();\n\n  /*\n    If you use Firebase you can forward and use the logged in Google user like this:\n  */\n  const credential = auth.GoogleAuthProvider.credential(googleUser.authentication.idToken);\n  return this.afAuth.auth.signInAndRetrieveDataWithCredential(credential);\n}\n```\n\n#### Vue 3\n\n```vue\n<script setup lang=\"ts\">\nimport { defineComponent, onMounted } from 'vue';\nimport { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';\n\nonMounted(() => {\n  GoogleAuth.initialize();\n});\n\nasync function logIn() {\n  const response = await GoogleAuth.signIn();\n  console.log(response);\n}\n</script>\n```\n\nor see more [CapacitorGoogleAuth-Vue3-example](https://github.com/reslear/CapacitorGoogleAuth-Vue3-example)\n\n### iOS\n\n1. Create in Google cloud console credential **Client ID for iOS** and get **Client ID** and **iOS URL scheme**\n\n2. Add **identifier** `REVERSED_CLIENT_ID` as **URL schemes** to `Info.plist` from **iOS URL scheme**<br>\n   (Xcode: App - Targets/App - Info - URL Types, click plus icon)\n\n3. Set **Client ID** one of the ways:\n   1. Set in `capacitor.config.json`\n      - `iosClientId` - specific key for iOS\n      - `clientId` - or common key for Android and iOS\n   2. Download `GoogleService-Info.plist` file with `CLIENT_ID` and copy to **ios/App/App** necessarily through Xcode for indexing.\n\nplugin first use `iosClientId` if not found use `clientId` if not found use value `CLIENT_ID` from file `GoogleService-Info.plist`\n\n### Android\n\nSet **Client ID** :\n\n1. In `capacitor.config.json`\n\n   - `androidClientId` - specific key for Android\n   - `clientId` - or common key for Android and iOS\n\n2. or set inside your `strings.xml`\n\nplugin first use `androidClientId` if not found use `clientId` if not found use value `server_client_id` from file `strings.xml`\n\n```xml\n<resources>\n  <string name=\"server_client_id\">Your Web Client Key</string>\n</resources>\n```\n\n**Refresh method**\n\nThis method should be called when the app is initialized to establish if the user is currently logged in. If true, the method will return an accessToken, idToken and an empty refreshToken.\n```ts\ncheckLoggedIn() {\n    GoogleAuth.refresh()\n        .then((data) => {\n            if (data.accessToken) {\n                this.currentTokens = data;\n            }\n        })\n        .catch((error) => {\n            if (error.type === 'userLoggedOut') {\n                this.signin()\n            }\n        });\n}\n```\n\n## Configure\n\n| Name                     | Type     | Description                                                                                                                   |\n| ------------------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------- |\n| clientId                 | string   | The app's client ID, found and created in the Google Developers Console.                                                      |\n| iosClientId              | string   | Specific client ID key for iOS                                                                                                |\n| androidClientId          | string   | Specific client ID key for Android                                                                                            |\n| scopes                   | string[] | Scopes that you might need to request to access Google APIs<br>https://developers.google.com/identity/protocols/oauth2/scopes |\n| serverClientId           | string   | This ClientId used for offline access and server side handling                                                                |\n| forceCodeForRefreshToken | boolean  | Force user to select email address to regenerate AuthCode <br>used to get a valid refreshtoken (work on iOS and Android)      |\n\nProvide configuration in root `capacitor.config.json`\n\n```json\n{\n  \"plugins\": {\n    \"GoogleAuth\": {\n      \"scopes\": [\"profile\", \"email\"],\n      \"serverClientId\": \"xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com\",\n      \"forceCodeForRefreshToken\": true\n    }\n  }\n}\n```\n\nor in `capacitor.config.ts`\n\n```ts\n/// <reference types=\"'@codetrix-studio/capacitor-google-auth'\" />\n\nconst config: CapacitorConfig = {\n  plugins: {\n    GoogleAuth: {\n      scopes: ['profile', 'email'],\n      serverClientId: 'xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com',\n      forceCodeForRefreshToken: true,\n    },\n  },\n};\n\nexport default config;\n```\n\n## API\n\n<docgen-index>\n\n* [`initialize(...)`](#initialize)\n* [`signIn()`](#signin)\n* [`refresh()`](#refresh)\n* [`signOut()`](#signout)\n* [Interfaces](#interfaces)\n\n</docgen-index>\n<docgen-api>\n<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->\n\n### initialize(...)\n\n```typescript\ninitialize(options?: InitOptions) => void\n```\n\nInitializes the GoogleAuthPlugin, loading the gapi library and setting up the plugin.\n\n| Param         | Type                                                | Description                        |\n| ------------- | --------------------------------------------------- | ---------------------------------- |\n| **`options`** | <code><a href=\"#initoptions\">InitOptions</a></code> | - Optional initialization options. |\n\n**Since:** 3.1.0\n\n--------------------\n\n\n### signIn()\n\n```typescript\nsignIn() => Promise<User>\n```\n\nInitiates the sign-in process and returns a Promise that resolves with the user information.\n\n**Returns:** <code>Promise&lt;<a href=\"#user\">User</a>&gt;</code>\n\n--------------------\n\n\n### refresh()\n\n```typescript\nrefresh() => Promise<Authentication>\n```\n\nRefreshes the authentication token and returns a Promise that resolves with the updated authentication details.\n\n**Returns:** <code>Promise&lt;<a href=\"#authentication\">Authentication</a>&gt;</code>\n\n--------------------\n\n\n### signOut()\n\n```typescript\nsignOut() => Promise<any>\n```\n\nSigns out the user and returns a Promise.\n\n**Returns:** <code>Promise&lt;any&gt;</code>\n\n--------------------\n\n\n### Interfaces\n\n\n#### InitOptions\n\n| Prop                     | Type                  | Description                                                                                                                                      | Default            | Since |\n| ------------------------ | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------ | ----- |\n| **`clientId`**           | <code>string</code>   | The app's client ID, found and created in the Google Developers Console. Common for Android or iOS. The default is defined in the configuration. |                    | 3.1.0 |\n| **`scopes`**             | <code>string[]</code> | Specifies the scopes required for accessing Google APIs The default is defined in the configuration.                                             |                    |       |\n| **`grantOfflineAccess`** | <code>boolean</code>  | Set if your application needs to refresh access tokens when the user is not present at the browser. In response use `serverAuthCode` key         | <code>false</code> | 3.1.0 |\n\n\n#### User\n\n| Prop                 | Type                                                      | Description                                                         |\n| -------------------- | --------------------------------------------------------- | ------------------------------------------------------------------- |\n| **`id`**             | <code>string</code>                                       | The unique identifier for the user.                                 |\n| **`email`**          | <code>string</code>                                       | The email address associated with the user.                         |\n| **`name`**           | <code>string</code>                                       | The user's full name.                                               |\n| **`familyName`**     | <code>string</code>                                       | The family name (last name) of the user.                            |\n| **`givenName`**      | <code>string</code>                                       | The given name (first name) of the user.                            |\n| **`imageUrl`**       | <code>string</code>                                       | The URL of the user's profile picture.                              |\n| **`serverAuthCode`** | <code>string</code>                                       | The server authentication code.                                     |\n| **`authentication`** | <code><a href=\"#authentication\">Authentication</a></code> | The authentication details including access, refresh and ID tokens. |\n\n\n#### Authentication\n\n| Prop               | Type                | Description                                      |\n| ------------------ | ------------------- | ------------------------------------------------ |\n| **`accessToken`**  | <code>string</code> | The access token obtained during authentication. |\n| **`idToken`**      | <code>string</code> | The ID token obtained during authentication.     |\n| **`refreshToken`** | <code>string</code> | The refresh token.                               |\n\n</docgen-api>\n\n## Migration guide\n\n#### Migrate from 3.3.x to 3.4.x\n\nInstall version 3.4.x:\n\n```sh\nnpm i --save @codetrix-studio/capacitor-google-auth@^3.4\n```\n\n#### Migrate from 3.2.x to 3.3.x\n\nInstall version 3.3.x:\n\n```sh\nnpm i --save @codetrix-studio/capacitor-google-auth^3.3\n```\n\nFollow instruction for you project [Updating from Capacitor 4 to Capacitor 5](https://capacitorjs.com/docs/updating/5-0).\n\n#### Migrate from 3.2.1 to 3.2.2\n\nfor `Android` in file `MainActivity.onCreate`\n\n```diff\n- this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{\n-   add(GoogleAuth.class);\n- }});\n+ this.registerPlugin(GoogleAuth.class);\n```\n\n#### Migrate from 3.1.x to 3.2.x\n\nInstall version 3.2.x:\n\n```sh\nnpm i --save @codetrix-studio/capacitor-google-auth^3.2\n```\n\nFollow instruction for you project [Updating from Capacitor 3 to Capacitor 4](https://capacitorjs.com/docs/updating/4-0).\n\n#### Migrate from 3.0.2 to 3.1.0\n\n```diff\n- GoogleAuth.init()\n+ GoogleAuth.initialize()\n```\n\n#### Migrate from 2 to 3\n\nInstall version 3.x.x:\n\n```sh\nnpm i --save @codetrix-studio/capacitor-google-auth^3.0\n```\n\nAfter [migrate to Capcitor 3](https://capacitorjs.com/docs/updating/3-0) updating you projects, see diff:\n\n##### WEB\n\n```diff\n- import \"@codetrix-studio/capacitor-google-auth\";\n- import { Plugins } from '@capacitor/core';\n+ import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth'\n\n- Plugins.GoogleAuth.signIn();\n+ GoogleAuth.init()\n+ GoogleAuth.signIn()\n```\n\n#### Migrate from 1 to 2\n\nInstall version 2.x.x:\n\n```sh\nnpm i --save @codetrix-studio/capacitor-google-auth@2\n```\n\nfor capacitor 2.x.x use [instruction](https://github.com/CodetrixStudio/CapacitorGoogleAuth/blob/79129ab37288f5f5d0bb9a568a95890e852cebc2/README.md)\n\n## License\n\n[MIT](./LICENSE)\n","readmeFilename":"README.md"}