Christen Press went for her sixth tournament goal but a shot from distance hit the crossbar in the 33rd minute and soon after she missed an open net from 30 yards.
With Canada pressing for a goal, substitute Rapinoe went in alone in the 87th minute and beat Stephanie Labbe.
Canada coach Kenneth Heiner-Moller said it was important that his team avoids complacency during qualifying. "We have to let go of the World Cup and we have to go into this like this is our big tournament for the next three years. But we'll be ready", the Dane added.
It was less than eight months ago that in another game of massive significance the Canadian women's soccer team left the pitch devastated. They'll play the U.S.in Sunday's meaningless final. The Canadian women have gone 0-29-6 against the Americans since, but have tied two of the last six meetings.
Canada's Christine Sinclair, who had three qualifier goals and is the all-time leader in global goals with 186, got behind the US defense and forced a save by Naeher in the 39th minute. We needed someone to break the line and maybe there isn't anyone better than Deanne Rose to make sure that we do break a line.
Facebook, Twitter fighting fake news linked to coronavirus
Jin said users who click on a hashtag related to the coronavirus will now be served with a "pop-up with credible information". Facebook has reaffirmed its commitment to limiting misinformation by working in conjunction with third-party fact-checkers.
Canada seemed to sense the urgency in the second half.
United States celebrates a goal by midfielder Samantha Mewis (3) shoots a free kick for a goal against Mexico during the second half of the CONCACAF Women's Olympic Qualifying soccer tournament at Dignity Health Sports Park.
Canada, the world's eighth-best team, hasn't lost a qualifier to anyone but the USA since 2004, the last time it failed to reach the Summer Games. Canada still has yet to concede a goal through four games in 2020.
Rebecca Quinn and the 19-year-old Riviere came into the Canadian starting 11 with Allysha Chapman and Jordyn Huitema moving to the bench.
Press fired a shot off the crossbar in the 32nd minute and Canadian striker Christine Sinclair's shot six minutes later was stopped by U.S. keeper Alyssa Naeher.
First case of coronavirus confirmed in Germany
The 20 US airports now doing thermal screening receive roughly 90 per cent of all inbound flights from China, according to CNN . The 2019 novel coronavirus spreads through the air when an infected person coughs or sneezes.
Press has received more opportunities on the field as of late with the absence of Alex Morgan, who is on maternity leave. But her attempted chip was too high.
"Costa Rica made it hard, but we dominated, we finally got one, and we were so solid defensively that we weren't going to give one up after that", said Canadian captain Christine Sinclair. "Canada once again proved they're a great team and they're well organized, and I think they're very discipline". The team finally broke through with Huitema's goal. And Sophie Schmidt made a big challenge to deny an American shot in the 54th.
Canada has finished as runner up to the United States in the last three qualifying tournaments.
Mexico made the field for the 2004 Olympics, but has not been back since. "But at the end of the day, it's a short (Olympic) tournament this summer and I think when we play anyone in the world we have a chance to win and that's how good the team is".
They join hosts Japan, Brazil, New Zealand, Britain, The Netherlands and Sweden at Tokyo 2020, with four places left for two teams from Asia, one from Africa and one from either Africa or South America.
What is happening inside coronavirus epicentre Wuhan?, World News
Another 41 cases have been confirmed overseas , including in Thailand, the United States, and Australia. The overall number of confirmed cases in China is 2,744 while more than 300 are critically ill.
Seven Asian teams are still in the running for Tokyo with two to advance from Australia, China, Chinese Taipei, Myanmar, South Korea, Thailand and Vietnam.