Created
July 27, 2020 12:08
-
-
Save alejovdev/9defc69e7d56297630803eddf7e8e072 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as functions from 'firebase-functions' | |
import * as service from './service.json' | |
import admin = require('firebase-admin') | |
const params = { | |
type: service.type, | |
projectId: service.project_id, | |
privateKeyId: service.private_key_id, | |
privateKey: service.private_key, | |
clientEmail: service.client_email, | |
clientId: service.client_id, | |
authUri: service.auth_uri, | |
tokenUri: service.token_uri, | |
authProviderX509CertUrl: service.auth_provider_x509_cert_url, | |
clientC509CertUrl: service.client_x509_cert_url, | |
} | |
admin.initializeApp({ | |
credential: admin.credential.cert(params), | |
databaseURL: 'https://yourprojecturl.firebaseio.com', | |
}) | |
export const getUserToken = functions.https.onCall(async (data) => { | |
try { | |
let res = await admin.auth().createCustomToken(data.uid) | |
return { error: false, data: res } | |
} catch (error) { | |
return { error: true, data: error } | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment