I am asking this question because it is included in an exercise solution, but it is possible I don't have enough knowledge yet to know why this should be obvious...
Let $\varphi:A\rightarrow B$ be a homomorphism of rings, $f:Y \rightarrow X$ with $Y = \text{Spec}B$ and $X = \text{Spec}A$ induced by $\varphi$. Then $f$ induces $f^{\#}:O_X \rightarrow f_*O_Y$ the usual way (which gives a family of morphisms but do not describe what they really do). So we have in particular, for $U$ any open set of $X$, a map (ring homomorphism) $f^{\#}_U:O_X(U) \rightarrow O_Y(f^{-1}(U))$.
Apparently, if $U = X$, then $f^{\#}_U = \varphi$ and it should be obvious. Why?! I don't know any definitions that tells me what $f^{\#}$ really does...
I know that $O_X(D(f))=A_f$ so if $U=X$ then $O_X(X) = O_X(D(1))=A_1=A$
and likewise, $O_Y(f^{-1}(X))=O_Y(Y)=B$
so it is true that $f^{\#}$ goes from $A$ to $B$, but why are they equal?
Does it help to know that $f^{\#}$ is injective?