在Chrome浏览器扩展程序中识别机器/用户的最佳方法是什么? [英] What is the best to identify machine/user in Google Chrome Extention?

查看:176
本文介绍了在Chrome浏览器扩展程序中识别机器/用户的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网络应用程序,并为它补充了Chrome扩展,它将后台数据发送到Web应用程序。现在,我想将这些数据发送到Web应用程序中相应的用户帐户。我应该使用什么方法?我应该如何处理身份验证?



我在考虑是否有某种方法来识别计算机ID或我可以在用户注册时注册的东西,但我看不到任何获取机器ID的方法。



请提出一个最佳实施方式。



谢谢!解决方案

这是我在我的扩展中需要跟踪机器的工作。

  var macId = null; 
chrome.storage.local.get('machine-id',function(item){
var storedMacId = item ['machine-id'];
if(!storedMacId){
storedMacId = Math.random()。toString(36).slice(2);
chrome.storage.local.set({'machine-id':storedMacId});
}
macId = storedMacId;
});

基本上,我将随机字符串分配给我的macId变量并将其存储在本地会话中。您可以与用户建立联系并使用它来跟踪不同的安装。如果您想跟踪所有由同一用户进行的安装,您可以使用同步替换本地(它可以在与用户的Google ID登录的所有Chrome浏览器中同步)。



希望这回答你的问题。



干杯!


I have a web app and complementing chrome extension for it, which sends data in background to the web app. Now, I want to send this data to the corresponding user account in the web app. What method should I use? How should I handle the authentication?

I was thinking if there was some way to identify machine ID or something which I can register while user is signing up, but I cannot see any method to get machine ID.

Please suggest a best way to implement this.

Thanks!

解决方案

Here is what I am doing in my extension where I need to track machines.

var macId = null;
chrome.storage.local.get('machine-id', function(item){
  var storedMacId = item['machine-id'];
  if(!storedMacId) {
    storedMacId = Math.random().toString(36).slice(2);
    chrome.storage.local.set({'machine-id':storedMacId});
  }
  macId = storedMacId;
});

Basically, I assign a random string to my macId variable and store it in the local session. You could potentially associate with a user and use it to track different installs. If you want to track all installs by the same user as one, you can replace local with sync (it syncs across all chrome browsers signed in with the users google id).

Hope this answers your question.

Cheers!

这篇关于在Chrome浏览器扩展程序中识别机器/用户的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆