Få kontostatus for dine kontoer i Sbanken. Spesielt aktuelt for barnekontoer, hvor det er mangelfull mulighet for å hente ut saldo.
Dette homeyscriptet vil bruke sbankens API for å hente ut kontostatus.
Det du må gjøre er å registrere en klient i sbanken beta utvikler portal. Sette fødselsnummer i koden under som customerID. Så må du bruke API-et for å hente ut en account ID for den kontoen du vil ha status for.
sbanken.js
let customerId ='xxxfødselsnummerxxx'let b = xxx base64encoded clientid : secret ....'let tokenEndpoint = 'https://auth.sbanken.no/identityserver/connect/token'// var basicAuth = btoa(encodeURIComponent(clientid) + ":" + encodeURIComponent(secret));// console.log("basic ", basicAuth)constresponse=awaitfetch(tokenEndpoint, {"headers": {"accept":"application/json","authorization":"Basic "+ b,"content-type":"application/x-www-form-urlencoded; charset=utf-8" },"body":'grant_type=client_credentials',"method":"POST"});let data =awaitresponse.json()var token = data['access_token']asyncfunctiongetAPI(path) {constbaseURL='https://api.sbanken.no/exec.bank/api/v1'let resp =awaitfetch(baseURL + path, {"headers": {"accept":"application/json","authorization":"Bearer "+ token,"content-type":"application/json","customerId": customerId },"method":"GET" });let data =awaitresp.json()return data}// Note.. You have to play with the API in postman to get the account ID that you would like to get status fromlet r =awaitgetAPI('/Accounts/xxx_accountid_xxx')console.log("=== Results ===")console.log(r)awaitsetTagValue("sbanken_linnea", {type:'number', title:'Linnea konto'},r.item.available)//console.log("response", data)