Skip to content

Latest commit

 

History

History
103 lines (71 loc) · 2.58 KB

oauth2.md

File metadata and controls

103 lines (71 loc) · 2.58 KB
title
OAuth2 Helpers

OAuth2 Helpers

This contains helpers for google.accounts.oauth2 namespace.

hasGrantedAllScopes()

  • Type
function hasGrantedAllScopes(
  tokenResponse: TokenResponse,
  firstScope: string,
  ...restScopes: string[]
): boolean;
  • Details

Helper method to access google.accounts.oauth2.hasGrantedAllScopes Checks if the user granted all the specified scope or scopes.

  • Example
import { hasGrantedAllScopes } from "vue3-google-signin";

const tokenResponse = // token response from google
const result = hasGrantedAllScopes(
  tokenResponse,
  "profile",
  "email",
  "https://www.googleapis.com/auth/drive"
);

console.log(result);

hasGrantedAnyScopes()

  • Type
function hasGrantedAnyScopes(
  tokenResponse: TokenResponse,
  firstScope: string,
  ...restScopes: string[]
): boolean;
  • Details

Helper method to access google.accounts.oauth2.hasGrantedAnyScopes Checks if the user granted any the specified scope or scopes.

  • Example
import { hasGrantedAnyScopes } from "vue3-google-signin";

const tokenResponse = // token response from google
const result = hasGrantedAnyScopes(
  tokenResponse,
  "profile",
  "email",
  "https://www.googleapis.com/auth/drive"
);

console.log(result);

revokeAccessToken()

  • Type
function revokeAccessToken(accessToken: string, done?: () => void);
  • Details

Helper method to access google.accounts.oauth2.revoke

The revoke method revokes all of the scopes that the user granted to the app. A valid access token is required to revoke the permission.

  • Example
import { revokeAccessToken } from "vue3-google-signin";

revokeAccessToken("ACCESS TOKEN FROM GOOGLE", () => {
  console.log("Token revoked");
});