smelling bivouacs" and stop blocking roads, the PM added.
Police have already arrested more than 300 people at the start of two weeks of protests by environmental campaigners.
Some activists glued themselves to government buildings early on Tuesday.
Speaking at a book launch, Mr Johnson said: "I am afraid that the security people didn't want me to come along tonight because they said the road was full of uncooperative crusties and protesters of all kinds littering the road.
"They said there was some risk that I would be egged."
What is Extinction Rebellion and what does it want?
The farmers joining Extinction Rebellion
Mr Johnson added protesters could learn from former PM Margaret Thatcher, who he said had taken the issue of greenhouse gases seriously long before activists such as Greta Thunberg were born.
"I hope that when we go out from this place tonight and we are waylaid by importunate nose-ringed climate change protesters, we remind them that she was also right about greenhouse gases."
Extinction Rebellion activists are protesting in cities around the world, including Berlin, Amsterdam and Sydney.
The Metropolitan Police said there have been 319 arrests in relation to the demonstrations since 00:01 BST on Tuesday.
Some 200 campaigners who camped overnight on streets in central London also faced arrest on Tuesday morning after being issued with warnings by police.
Activists who blocked Horseferry Road, in Westminster, throughout the night were warned that they will be arrested unless they move to nearby Trafalgar Square.
But many said they were prepared to stay in the camp. Mike Gumn, 33, from Bristol, told the PA news agency: "We will decide as a group when we are going to move and we are not going to let police tell us when."
'A last resort'
By Becky Morton, BBC News
Behind Parliament Square there are dozens of tents where protesters from Scotland, Cumbria and north-east England have camped overnight.
Mikaela Loach, 21, travelled from Edinburgh on Monday with a friend on a bus organised for protesters.
She says she has attended protests before but this is her first time camping out overnight.
"I was a bit worried about police coming in the middle of the night, but it was a nice atmosphere having people around you that are here for the same cause," she said.
"I've spoken to my local MP, I've taken part in protests, I just feel like I haven't been listened to. This is a last resort," she said.
"I have been changing things in my lifestyle for a long time to try and be more eco-friendly, but I had a realisation that it doesn't matter if I go vegan or zero waste if the government doesn't do anything.
"There need to be big structural changes."
Some activists glued themselves to the Department for Transport building early on Tuesday, a tactic used in demonstrations earlier this year.
A lorry was also parked on Marsham Street, outside the entrance to the Home Office, with protesters attaching themselves to the vehicle.
On Monday, organisers blockaded key sites in central London, in addition to demonstrating outside government departments.
Some glued and chained themselves to roads and vehicles - those who did so outside Westminster Abbey were later removed by police.
The roads behind Downing Street were blocked throughout the day by protesters, some of whom had erected tents in the street and were sitting down and singing songs together.
The protests are calling for urgent action on global climate and wildlife emergencies.
Further road closures are expected on Tuesday, with Parliament Street, Great Smith Street and Westminster and Lambeth bridges predicted to be heavily affected.
Extinction Rebellion claims protests in the capital will be five times bigger than similar events in April, which saw more than 1,100 people were arrested.
What is Extinction Rebellion?
Extinction Rebellion (XR for short) wants governments to declare a "climate and ecological emergency" and take immediate action to address climate change.
It describes itself as an international "non-violent civil disobedience activist movement".
Extinction Rebellion was launched in 2018 and organisers say it now has groups willing to take action in dozens of countries.
In April, the group held a large demonstration in London that brought major routes in the city to a standstill.