我们即将将该项目投入生产。
1-我们的移动应用程序会通过将其发布到我们的内部Microserve中来创建汇款。这样的发布请求将返回从我们内部的NodeJs服务器生成的CustomToken。
2-我们的内部微服务会将此类传输复制到Firestore,并相应地更新其在Firestore上的状态。
3-代替我们的Mobilie App民意调查或监听我们的内部微服务以获取状态,它会监听Firestore以从相应文档中获取状态。为了进行侦听,它将使用在步骤1中从帖子返回的CustomToken。我们公司仅希望利用Google Firestore的Real Time Database功能来进行此项目(反应性方法)。
与以下陈述相比,我在考虑什么/问题:“在大多数情况下,Google倾向于您授权使用服务帐户”? (从other related discussion复制)
CustomToken是使用此NodeJs服务器在内部创建的,并取决于从固定用户authentication/users from Google Firebase提取的uid >>
const admin = require('firebase-admin'); exports.serviceAccount = { "type": "service_account", "project_id": "firetestjimis", "private_key_id": "ecfc6 ... fd05923", "private_key": "-----BEGIN PRIVATE KEY-----\nMIIE .... 5EKvQ==\n-----END PRIVATE KEY-----\n", "client_email": "[email protected]", "client_id": "102422819688924138150", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-fg6p9%40firetestjimis.iam.gserviceaccount.com" } admin.initializeApp({ credential: admin.credential.cert(exports.serviceAccount) }); var uid = "NS .... Ro2"; //copied from https://console.firebase.google.com/project/firetestjimis/authentication/users var claim = { control: true }; admin.auth().createCustomToken(uid) .then(function (customToken) { console.log(customToken) }) .catch(function (error) { console.log("Error creating custom token:", error); });
我们的移动设备(在Angular中为示例,但IOS和Android的想法相同)具有我这样下载的SERVICE_ACCOUNT_JSON_FILE:
environment.ts:
export const environment = { production: false, firebaseConfig: { apiKey: "AIzaSy ... 3DCGihK3xs", authDomain: "firetestjimis.firebaseapp.com", databaseURL: "https://firetestjimis.firebaseio.com", projectId: "firetestjimis", storageBucket: "firetestjimis.appspot.com", messagingSenderId: "795318872350", appId: "1:7953 ... 32b26fb53dc810f" } };
app.component.ts
public transfers: Observable<any[]>; transferCollectionRef: AngularFirestoreCollection<any>; constructor(public auth: AngularFireAuth, public db: AngularFirestore) { this.listenSingleTransferWithToken(); } async listenSingleTransferWithToken() { await this.auth.signInWithCustomToken("eyJh ### CUSTOMTOKEN GENERATED FROM INTERNAL NODEJS SERVER ABOVE ### CVg"); this.transferCollectionRef = this.db.collection<any>('transfer', ref => ref.where("id", "==", "1")); this.transfers = this.transferCollectionRef.snapshotChanges().map(actions => { return actions.map(action => { const data = action.payload.doc.data(); const id = action.payload.doc.id; return { id, ...data }; }); }); } }
我了解,CustomToken的创建及其在我们的移动设备中的使用完全依赖于服务帐户。我对吗?我是否错过了某些概念,并且在后台使用了USER CREDENTIAL,并且在DEV环境中正常工作的某些东西在生产时会突然弹出?显然,此问题全部来自我的免费帐户,但在生产中将是付费帐户,但此处的代码和步骤将完全相同。
***在约翰的评论后编辑
独立的环境。ts进入浏览器。如果存在问题,也许有经验的Angular Dev可以聆听Firestore文档可以发表评论
我们即将将该项目投入生产。 1-我们的移动应用将通过将其发布到我们的内部Microserve中来创建汇款。此类发布请求将返回从我们的...
据我所知,您当前定制该定制的方式完全基于服务帐户,以及您对用户UID(从控制台复制的UID)的隐式了解。据我所知,您共享的代码以及流程的其他部分都没有涉及其他用户凭据。