Try to give off trustworthy vibes and pick customers/clients/employers who will trust you.
I'm not going to pretend it always worked for me, but it certainly got easier once I could demonstrate a wealth of experience.
There's a lot of luck, too.
In terms of refactoring, I have an iron rule that I never ask for permission. If I think it needs doing I do it. I don't justify it to product or ask for their opinion. Technical issues and priorities are on a need to know basis and they don't need to know. All the work gets baked into feature work and bugfixes.
I'm not going to pretend it always worked for me, but it certainly got easier once I could demonstrate a wealth of experience.
There's a lot of luck, too.
In terms of refactoring, I have an iron rule that I never ask for permission. If I think it needs doing I do it. I don't justify it to product or ask for their opinion. Technical issues and priorities are on a need to know basis and they don't need to know. All the work gets baked into feature work and bugfixes.