I guess this depends on your definition of "trust", so I will offer two takes on that.
First, trust is most easily earned when it is least necessary: The more open and transparent one side can be, the less need there is to "just trust them". If I can see, somehow, that you have no rational reason to betray me, harm me, or rob me, I have no rational reason to push you away. On the other hand, the more secrets somebody insists upon keeping, the more they won't tell you, the less you trust them. Even if secretly the secrets they keep have nothing to do with you.
(In fact, one secret of con men is creating the illusion of openness with a fabricated past and present they are eager to share, thus creating trust).
So there is probably some character on side A that is already the "most open", and some character on side B that is already the "most open" on side B. One of these could be the main characters but this idea works if neither is: Those two chatterboxes get together and can't help themselves, the openness escalates from hints to full disclosure. Then they go back to their groups, and BAM, everybody knows everything about the other group and what it is doing. They may still be cautious, but trust is born, and they can use each other's help.
Another option in this vein is a reverse dunk, trust by subterfuge. Side A hacks side B, or eavesdrops on them, or somehow gains intel on them without side B knowing it. By reviewing the information they gained, side A realizes side B is all-in for the same goal as them. so through this subterfuge side A now trusts side B, but not vice versa. They earn the trust of side B by being open, perhaps not about spying on them, but at least open about their goals and activities.
In a similar vein, the other big option I mentioned is to skip the trust and go to the consequences of trust, out of desperation. What are the consequences of trust? Putting your fate in the hands of another, risking something with no guarantee, a willingness to do something on speculation.
If side A is about to unravel or crash for some reason, they may have little to lose by acting as if they trust side B: In other words, the more at risk they are, the higher their tolerance for any distrust of side B.
When you are slipping down the mountain, you don't worry if the stranger offering you a helping hand might just be after your gold watch.