package Ġfl ank . scripts . ops . firebase Ċ Ċ import Ġfl ank . common . default Credential Path Ċ import Ġfl ank . common . download File Ċ import Ġjava . io . File Ċ import Ġjava . nio . file . Path Ċ Ċ fun Ġsave ServiceAccount ( ĊĠĠĠ Ġservice Account : ĠString , ĊĠĠĠ Ġservice Account Path : ĠPath Ġ= Ġdefault Credential Path . to AbsolutePath () Ċ ) Ġ{ ĊĠĠĠ Ġservice Account Path . parent . to File (). mkdir s () ĊĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠĠĠ Ġservice Account . startsWith (" http ", Ġtrue ) Ġ-> Ġdownload File ( service Account , Ġservice Account Path ) ĊĠĠĠĠĠĠĠ Ġservice Account . endsWith (". json ", Ġtrue ) Ġ-> Ġsave FromFile ( service Account , Ġservice Account Path ) ĊĠĠĠĠĠĠĠ Ġelse Ġ-> Ġsave From Str ( service Account , Ġservice Account Path ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġfun Ġsave FromFile ( ĊĠĠĠ Ġpath : ĠString , ĊĠĠĠ Ġservice Account Path : ĠPath Ġ= Ġdefault Credential Path . to AbsolutePath () Ċ ) Ġ{ ĊĠĠĠ ĠFile ( path ). copy To ( service Account Path . to File (), Ġoverwrite Ġ= Ġtrue ) Ċ } Ċ Ċ private Ġfun Ġsave From Str ( ĊĠĠĠ Ġservice Account Data : ĠString , ĊĠĠĠ Ġservice Account Path : ĠPath Ġ= Ġdefault Credential Path . to AbsolutePath () Ċ ) Ġ{ ĊĠĠĠ Ġservice Account Path . to File (). write Text ( service Account Data ) Ċ } Ċ