This file contains 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
try { | |
const pushTokenDoc = await db.collection(`push_tokens/${userRef.id}`).doc(); | |
const token = pushTokenDoc.data().token; | |
const title = 'TITLE'; | |
const message = 'MESSAGE'; | |
const payload = { | |
notification: { | |
title: title, |
This file contains 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
const functions = require("firebase-functions"); | |
const serviceAccount = require("./service-account.json"); | |
const { initializeApp, cert } = require('firebase-admin/app'); | |
const { getAuth } = require('firebase-admin/auth'); | |
const app = initializeApp({ | |
credential: cert(serviceAccount) | |
}) | |
const auth = getAuth(app) | |
exports.protectedEndpoint = functions.https.onRequest(async (request, response) => { | |
try { |
This file contains 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
➜ ~ curl https://us-central1-givemefirebasetoken-sample.cloudfunctions.net/protectedEndpoint | |
{"error":"'x-api-token' header is required!"}% |
This file contains 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
curl --location --request POST '<https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=AIzaSyAHV1eUu8EqCSUeycofXqfL******>' \\ | |
--header 'Content-Type: application/json' \\ | |
--data-raw '{ | |
"email": "anton.krasov@gmail.com", | |
"password": "******", | |
"returnSecureToken": true | |
}' |
This file contains 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
{ | |
"kind": "identitytoolkit#SignupNewUserResponse", | |
"idToken": "eyJhbGciOiJSUzI1NiIsImtpZ....gkULJig1ypXaA", | |
"email": "anton.krasov@gmail.com", | |
"refreshToken": "AIwUaOkfNuMg8Kdatx-Hy8_5Ti0sm....-dKiN0CGkDfX1ch5f69g5Y5K", | |
"expiresIn": "3600", | |
"localId": "aoiC7bM0v....ueGMRegf1k2" | |
} |
This file contains 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
curl --location --request GET '<https://us-central1-givemefirebasetoken-sample.cloudfunctions.net/protectedEndpoint>' \\ | |
--header 'x-api-token: eyJhbGciOiJSUzI1NiIsImtpZ....09HlrF49MRWo9qq0_c6UiMHdBZUavNXyuFyjC85dpSxJrNtJSwH5OQa22dIwdbNmfMqz6ljAivIkjw5aX2GrF5ViFCdp4Tew5iw' |
This file contains 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
{ | |
"decodedToken": { | |
"iss": "<https://securetoken.google.com/givemefirebasetoken-sample", | |
"aud": "givemefirebasetoken-sample", | |
"auth_time": 1651977397, | |
"user_id": "aoiC7bM0vFQTMPj24ueGMRegf1k2", | |
"sub": "aoiC7bM0vFQTMPj24ueGMRegf1k2", | |
"iat": 1651977397, | |
"exp": 1651980997, | |
"email": "anton.krasov@gmail.com", |
This file contains 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
var jsonData = JSON.parse(responseBody); | |
pm.expect(jsonData.idToken).to.be.a('string'); | |
postman.setEnvironmentVariable("firebaseIdToken", jsonData.idToken); |
This file contains 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
const firebaseApiKey = pm.environment.get("firebaseApiKey") | |
const firebaseTestUserEmail = pm.environment.get("firebaseTestUserEmail") | |
const firebaseTestUserPassword = pm.environment.get("firebaseTestUserPassword") | |
const options = { | |
url: `https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=${firebaseApiKey}`, | |
method: 'POST', | |
header: { | |
'Accept': '*/*', | |
'Content-Type': 'application/json', |
This file contains 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 'package:flutter/material.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:integration_test/integration_test.dart'; | |
import 'package:taskezdev/main.dart' as app; | |
import 'package:taskezdev/main.dart'; | |
import 'helpers.dart'; | |
void main() { |
OlderNewer