问题
I am implementing a chrome extension. Where an user log in(email and password) and get auth token from 3rd party. I want to store this auth token so when sending another request to same party I can use this token. What is good approach to do this. Should I store it ? If yes how? Else what should I do?
回答1:
you can save it in Storage
Step 1 :- You need to add the permission in menifist
, json
"permissions": [ "storage" ],
Steps 2 :- Set token to the storage
chrome.storage.local.set({ "auth_Tokan": <YOUR_TOKAN_HERE> }, function(){
// Data's been saved boys and girls, go on home
});
Steps 3 :- Get the token from the storage
var Auth_Tokan='';
chrome.storage.local.get(["auth_Tokan"], function(items){
debugger;
//NOTE:-check syntax here, i am not sure for access 'Auth_Tokan'
auth_tokan= items.Auth_Tokan
});
来源:https://stackoverflow.com/questions/48077497/get-and-store-auth-token-in-chrome-extension