By simple observations, it would be easy to deduce that $m=-1$
This can also be proved by the following figure 
Where the line $y=-x+1$ subtends $\frac{\pi}{2}$ at the centre.
But the answer says $m=-1\pm \sqrt 2$
I found that the given value of m can be obtained by homogenising the equation, bu thay still doesn’t explain the diagram. Please clarify

Actually, the answer that I got was $\pm\left(1-\sqrt2\right)$.
The line $y=1+mx$ and the circle $x^2+y^2=1$ have two points in common: $(0,1)$ and $\left(-\frac{2m}{m^2+1},-\frac{m^2-1}{m^2+1}\right)$. You're after those $m$'s such that$$(0,1).\left(-\frac{2m}{m^2+1},-\frac{m^2-1}{m^2+1}\right)=\cos\left(\frac\pi4\right)=\frac1{\sqrt2}.$$This is equivalent to $\frac{1-m^2}{1+m^2}=\frac1{\sqrt2}$ and this occurs if and only if $m=\pm\left(1-\sqrt2\right)$.