Criterion for Affine Scheme via Glueing Let $X$ be a scheme. Futhermore we denote for a global section $s \in \Gamma(X,\mathcal{O}_X)$  the non vanishing set
$$X_s := \{x \in X | s_x \neq 0 \}$$
(remark: $s_x$ is the image of $s$ under the canonical map $\Gamma(X,\mathcal{O}_X) \to \mathcal{O}_{X,x}/m_x =k(x)$ <- (residue field of the stalk at $x$)
My question is how to show that if we know that there exist a finite number of global sections $t_i \in \Gamma(X,\mathcal{O}_X)$ such that


*

*1) $X_{t_i}$ are open affine

*2) $X = \cup_i X_{t_i}$, so $X_{t_i}$ cover $X$

*3) the $t_i$ (by assumption finitely many) generate the global sections ring $\Gamma(X, \mathcal{O}_X)$
Then $X$ is affine!
I tried to show following:
Denote $R := \Gamma(X,\mathcal{O}_X)$ and $R_i := \Gamma(X_{t_i},\mathcal{O}_X)$
I have two problems:
Firstly, to show that $R_{t_i}= \Gamma(X_{t_i},\mathcal{O}_X) = R_i$ (here $R_{t_i}$ is the localization of $R$ wrt $t_i$). How to verify it?
Secondly: after hoving shown 1) a would like to glue these isomorphisms $R_{t_i} \to  \Gamma(X_{t_i},\mathcal{O}_X)$ to an iso $R \to \Gamma(X,\mathcal{O}_X)$.
Locally, on $X_{t_i}$,  the induced morphisms $X_{t_i} \to Spec(R_{t_i}$ between specs are by 1)  isomorphisms of schemes. Does here already a glueing argument work. How concretely?
I often read that for similar local constructions one uses such "glueing arguments" but here on this example I would be glad to see this glueing concretely "in action" to become a better intuition when it works and when not.
 A: This argument comes from Vakil's notes, specifically the proof of the Qcqs lemma. This is lemma 7.3.5 in the November 18th, 2017 version of his notes.
Use the sheaf property.
We have exactness of 
$$\newcommand\Spec{\operatorname{Spec}}0\to \Gamma(X,\newcommand\calO{\mathcal{O}}\calO_X)\to \prod_i \Gamma(X_i,\calO_X)\to \prod_{\{i,j\}} \Gamma(X_{ij},\calO_X),$$
where $X_{ij}=X_i\cap X_j = (X_i)_{t_j}$. Now let $R_i=\Gamma(X_i,\calO_X)$, and note that $X_{ij}=\Spec R_{ij}$ is affine, where $R_{ij}:=\Gamma(X_{ij},\calO_X)=(R_i)_{t_j}=(R_j)_{t_i}$, since $X_i$ is affine. 
Now for any $s\in \Gamma(X,\calO_X)$, localize this sequence at $s$. Since localization is exact, this preserves exactness. Also use the fact that the products are finite, so that we have that localization distributes over them. Thus we have
$$0\to \Gamma(X,\calO_X)_s \to \prod_i (R_i)_s \to \prod_{\{i,j\}} (R_{ij})_s.$$
Note that $X_s = \bigcup_i (X_i)_s$, and the $X_i$s and $X_{ij}$s are affine, so we also have exactness of
$$0\to \Gamma(X_s,\calO_X) \to \prod_i (R_i)_s \to \prod_{\{i,j\}} (R_{ij})_s,$$ 
and we have natural maps downwards from the first sequence to the second. Since the second and third maps are isomorphisms, the first is as well. Applying this to $s=t_i$, we have the desired isomorphisms, $R_i\simeq R_{t_i}$.
Thus you have shown that locally on the target, the natural map $X\to \Spec R$ is an isomorphism, and thus $X\to \Spec R$ is an isomorphism.
