Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@hristo2612/capacitor-google-auth
Advanced tools
Capacitor Plugin for authenticating Google Users
Capacitor plugin for Google Auth. ( This is a fixed version of @codetrix-studio/capacitor-google-auth for Capacitor 3+
PRs are welcome and much appreciated that keeps this plugin up to date with Capacitor and official Google Auth platform library feature parity.
Try to follow good code practices. You can even help keeping the included demo updated.
PRs for features that are not aligned with the official Google Auth library are discouraged.
(We are beginner-friendly here)
npm i @hristo2612/capacitor-google-auth
npx cap update
Add clientId
meta tag to head in index.html.
<meta name="google-signin-client_id" content="{your client id here}" />
Register plugin and manually initialize
import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
// use hook after platform dom ready
GoogleAuth.init();
Use it
GoogleAuth.signIn();
init hook & sign in function
import { GoogleAuth } from '@hristo2612/capacitor-google-auth';
import { AngularFireAuth } from '@angular/fire/auth';
import firebase from 'firebase/app';
import 'firebase/auth';
// app.component.ts
constructor(private afAuth: AngularFireAuth) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
GoogleAuth.init();
});
}
async googleSignIn() {
let googleUser = await GoogleAuth.signIn();
const credential = firebase.auth.GoogleAuthProvider.credential(googleUser.authentication.idToken);
return this.afAuth.signInWithCredential(credential);
}
Make sure you have GoogleService-Info.plist
with CLIENT_ID
Add REVERSED_CLIENT_ID
as url scheme to Info.plist
Inside your strings.xml
<resources>
<string name="server_client_id">Your Web Client Key ( Same as the one in the index.html meta tag )</string>
</resources>
Import package inside your MainActivity
import com.hristo2612.capacitor.google.auth;
Register plugin inside your MainActivity.java
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerPlugin(GoogleAuth.class);
}
}
Provide configuration in root capacitor.config.json
{
"plugins": {
"GoogleAuth": {
"scopes": ["profile", "email"],
"serverClientId": "xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"forceCodeForRefreshToken": true
}
}
}
Note : forceCodeForRefreshToken
force user to select email address to regenerate AuthCode used to get a valid refreshtoken (work on iOS and Android) (This is used for offline access and serverside handling)
FAQs
Capacitor Plugin for authenticating Google Users
The npm package @hristo2612/capacitor-google-auth receives a total of 2 weekly downloads. As such, @hristo2612/capacitor-google-auth popularity was classified as not popular.
We found that @hristo2612/capacitor-google-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.