This is exercise II.2.4 in Hatshorne:
Let $A$ be a ring and $(X,\mathcal{O}_X)$ a scheme. We have the associated map of sheaves $f^\#: \mathcal{O}_{\text{Spec } A} \rightarrow f_* \mathcal{O}_X$. Taking global sections we obtain a homomorphism $A \rightarrow \Gamma(X,\mathcal{O}_X)$. Thus there is a natural map $\alpha : \text{Hom}(X,\text{Spec} A) \rightarrow \text{Hom}(A,\Gamma(X,\mathcal{O}_X))$. Show $\alpha$ is bijective.
We can find a map $\beta: \text{Hom}(A,\Gamma(X,\mathcal{O}_X)) \rightarrow \text{Hom}(X,\text{Spec} A)$ by sending a map $g: A \rightarrow \Gamma(X,\mathcal{O}_X)$ to a map from $X$ to $\text{Spec} A$ defined as follows:
First taking affine open cover of $X = \cup \, \text{Spec} A_i$, then taking spectrum of the map $g$ (after being composed with the restriction map, i.e. consider $g_i: A \rightarrow A_i$ and take $\text{Spec} g_i$), and glue them together. Details are in the post: Prove that the natural map $\alpha : \text{Hom}(X,\text{Spec} A) \rightarrow \text{Hom}(A,\Gamma(X,\mathcal{O}_X))$ is an isomorphism.
My question is: How to show the map $\alpha$ and $\beta$ are inverse to each other?
The question in affine case is casual, where $\alpha$ is simply "taking global sections" and $\beta$ is "taking spectrum". These two are "inverse" to each other indeed. Yet how to show this in the general case on scheme (not just affine schemes). In other word, the adjunction of $\Gamma$ and $\text{Spec}$ is in affine case, hence is "local". Yet how to "glue these adjunctions"?
Any direct proof on "the map $\alpha$ and $\beta$ are inverse to each other" is welcomed :)
P.S. I know that there is a proof in broader context on locally ringed space, i.e. https://stacks.math.columbia.edu/tag/01I1, but I still hope to practice the method of gluing things.