小编ndo*_*m91的帖子

在 M1 Mac 上以 arm64 模式运行 tmux

所以我通过arm64 homebrew安装了tmux。

我最初为 arm64 手动编译了 alacritty(我最喜欢的终端模拟器),因此它在 arm64 模式下运行。uname -a确认我们处于arm64中。

Darwin ndo-mbp.local 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:10 PDT 2020; root:xnu-7195.50.7~2/RELEASE_ARM64_T8101 arm64
Run Code Online (Sandbox Code Playgroud)

然后我安装了 homebrew,它缓慢但肯定地为大多数流行的应用程序提供了arm64瓶子,包括tmuxhttps://github.com/Homebrew/brew/issues/7857)。所以我从arm64 shell安装了它,它编译成功。

如果我运行file $(which tmux)我会得到:

/opt/homebrew/bin/tmux: Mach-O 64-bit executable arm64
Run Code Online (Sandbox Code Playgroud)

但是,如果我tmux在 arm64 alacritty 中启动该二进制文件,我似乎会进入 x86_64 模式。uname -a从 tmux 窗口内部运行我得到:

Darwin ndo-mbp.local 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:10 PDT 2020; root:xnu-7195.50.7~2/RELEASE_ARM64_T8101 x86_64
Run Code Online (Sandbox Code Playgroud)

知道这是怎么回事吗?我对 Mac 操作系统比较陌生,所以也许我遗漏了一些明显的东西。

tmux apple-m1

13
推荐指数
1
解决办法
7713
查看次数

通过 api 路由/强大的 next.js 文件上传 - 不工作

我在通过 api 路由上传文件时遇到了很多麻烦。

在客户端,我像这样提交文件:

 onFormSubmit = (e) => {
    e.preventDefault() // Stop form submit

    this.fileUpload(this.state.file).then((response) => {
      console.log('rD', response.data)
    })
 }

 onFileChange = (e) => {
    this.setState({ file: e.target.files[0] })
 }

 fileUpload = (file) => {
    const url = '/api/mail/upload'
    const formData = new FormData()
    formData.append('file', file)
    const config = {
      headers: {
        'X-CSRF-TOKEN': this.props.session.csrfToken
      }
    }
    return axios.post(url, formData, config)
 }
Run Code Online (Sandbox Code Playgroud)

我的请求/api/mail/upload是这样的:

Request Headers:
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,de-DE;q=0.8,de;q=0.7
Connection: keep-alive
Content-Length: …
Run Code Online (Sandbox Code Playgroud)

file-upload formidable reactjs next.js

7
推荐指数
3
解决办法
5528
查看次数

客户端未经授权使用此方法检索访问令牌服务帐户错误

让我的服务帐户在同一个 web 应用程序上进行身份验证是一件非常令人头疼的事情,我也让用户通过 oauth2 登录。

所以我想知道,这可能吗?

如果不是,是否应该坚持使用服务帐户?是否必须自行对用户进行身份验证(老派风格)?哈哈

谢谢。

关于服务帐户,我已经启用了域范围委托,在我的 G Suite 管理控制台中启用了客户端密钥 + api 范围,并且已经获得了 php 示例,并且书籍 api 正常工作。然而,每当我尝试除书籍之外的任何其他 api 时,我都会收到错误,

客户端无权使用此方法检索访问令牌

更新:我尝试使用@dalmto的示例,并添加了几行来测试gmail api,例如:

putenv('GOOGLE_APPLICATION_CREDENTIALS=credentials.json');

$user = 'email@domain.de';

function getGoogleClient() {
    return getServiceAccountClient();
}

function getServiceAccountClient() {
    try {
        // Create and configure a new client object.
        $client2 = new Google_Client();
        $client2->useApplicationDefaultCredentials();
        $client2->setScopes(array('https://www.googleapis.com/auth/userinfo.email','https://www.googleapis.com/auth/admin.directory.user.readonly','https://www.googleapis.com/auth/userinfo.profile','https://www.googleapis.com/auth/gmail.readonly','https://www.googleapis.com/auth/calendar'));
        $client2->setAccessType('offline');
        $client2->setSubject($user);
        return $client2;
    } catch (Exception $e) {
        print "An error occurred: " . $e->getMessage();
    }
}

$newGoogleClient = getGoogleClient();

$service3 = new …
Run Code Online (Sandbox Code Playgroud)

php google-oauth service-accounts gmail-api google-workspace

5
推荐指数
1
解决办法
8231
查看次数