保持Google登录状态

时间:2020-04-18 19:38:42

标签: oauth-2.0 google-api google-oauth google-api-client

我是Google API的新手。我正在尝试在我的网站中构建一个Google登录按钮。我试图避免使用其内置按钮。下面的代码可用于登录用户,但我无法弄清楚如何使我的网页记住用户刷新页面,浏览更多网站页面或离开站点并返回时它们已登录。 / p>

struct Test<'a>(Option<BoxFuture<'a, ()>>);

impl Test<'_> {
    async fn function(&mut self) {
        println!("I'm alive!");
    }

    fn new() -> Self {
        let mut s = Self(None);
        // fuck the police
        s.0 = Some(unsafe { &mut *(&mut s as *mut Self) }.function().boxed());
        s
    }
}

impl Future for Test<'_> {
    type Output = ();
    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
        self.0.as_mut().unwrap().poll_unpin(cx)
    }
}

请在上面的代码中实现您的代码,这样我会更好地了解事情的进展。 任何帮助,不胜感激!

0 个答案:

没有答案