Strongly recommend the following threads, especially the comprehensive answers from @voracityemail within them:
The system has a few gotchas and idiosyncasies (to put it diplomatically) and most of the ones related to authorisation will likely be covered in those two.
Alternatively ordering this forum by number of views will tend to bring bigger threads, especially about connectivity and authentication to the top as you are far, far from the only person to have issues at this point!
If you let us know how you are accessing (what language etc) and what the exact issue is with regards to not working as expected. Then someone here (and more often than not voracityemail, may be able to assist). While Companies House can respond to technical issues on their end and specific questions about usage, they are very limited in the technical support they can offer (there are legislative reasons for this) and can’t really help troubleshoot, so you may be reliant on feedback from other developers on here.
Edit: Also this page may be helpful Authenticating requests | CH Guide (a great resource, although not sure if it is still being maintained).