Skip to content

Instantly share code, notes, and snippets.

@tianhaoz95
Last active January 15, 2020 23:47
Show Gist options
  • Save tianhaoz95/c2a55f383062e40ff656b8084c0abfbe to your computer and use it in GitHub Desktop.
Save tianhaoz95/c2a55f383062e40ff656b8084c0abfbe to your computer and use it in GitHub Desktop.
Token to context Firebase implementation
async token2context(token: string): Promise<FunctionContext> {
const context: FunctionContext = { authenticated: false, uid: "na" };
try {
const verifyResult = await this.auth.verifyIdToken(token);
context.authenticated = true;
context.uid = verifyResult.uid;
} catch (err) {
console.log(err);
}
return context;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment