Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
react-google-oauth2
Advanced tools
Easily add Google OAuth 2.0 Single Sign On to a React app & let your server handle your access & refresh tokens. This library will work directly with Flask JWT Router & provide Google OAuth 2.0 integration out of the box with minimal setup.
Docs: https://joegasewicz.github.io/react-google-oauth2.0/
npm install react-google-oauth2
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
GoogleButton,
IAuthorizationOptions,
isLoggedIn,
createOAuthHeaders,
logOutOAuthUser,
} from "../src";
function App(props: any) {
const options: IAuthorizationOptions = {
clientId: (process.env.CLIENT_ID as string),
redirectUri: "http://localhost:3000/react-google-Oauth2.0/dist/index.html",
scopes: ["openid", "profile", "email"],
includeGrantedScopes: true,
accessType: "offline",
};
return (
<>
<GoogleButton
placeholder="demo/search.png" // Optional
options={options}
apiUrl="http://localhost:5000/google_login"
defaultStyle={true} // Optional
/>
</>
);
}
ReactDOM.render(
</App>,
document.getElementById("main"),
);
Check if OAuth2.0 user is logged in
if(isLoggedIn()) { // returns true is accessToken exists in LocalStorage
// user logged code...
}
Creat OAuth2.0 Server Headers
// Using Fetch API example:
fetch(url, {
headers: createOAuthHeaders(),
});
Log out OAuth2.0 users
logOutOAuthUser() // removes the accessToken from LocalStorage
The GoogleButton
component will make the following request to your api:
POST options = {body: { code: <code>, email: <email>, scope: <scope> }} URL = `apiUrl`
If you are using Flask as your REST api framework then this library is designed to work
directly with flask-jwt-router
. See Flask JWT Router
for more details.
FAQs
React frontend login with OAuth 2.0 & integrates a Rest API backend.
We found that react-google-oauth2 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.