---
title: 简易教程：用命令行从 macOS、Linux 上传照片至 Google 相册
date: 2020-02-28T08:36:45Z
modified: 2020-02-28T11:31:40Z
permalink: "https://www.appinn.com/gphotos-uploader-cli/"
type: post
status: publish
excerpt: ""
categories:
  - macOS
tags:
  - macOS
  - Google Photos
  - Google 相册
  - twp
  - 命令行
  - 开源
featured_image: "https://www.appinn.com/wp-content/uploads/2020/02/google-photos-uploader-cli.jpgo_.jpg"
author: 青小蛙
timestamp: 2020-02-28T11:31:40Z
---

**[Google Photos uploader CLI](https://www.appinn.com/gphotos-uploader-cli.md)** 是一款第三方的 Google 相册批量上传命令行工具，只需要简单的配置之后，即可非常方便的上传整个文件夹的照片。

![](https://static2.appinn.com/images/202002/google-photos-uploader-cli.jpg)

Photo by [Miguel Ferreira](https://unsplash.com/@mikeferreira?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/album?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)

Google 相册针对高分辨率提供了无限制的存储空间，非常适合用作照片备份；以及其有趣的「为您推荐」功能，也适合平时使用，因为它时常会带来惊喜。

至于 Google 相册官方提供了上传工具，为什么还要用命令行，那就是看个人喜好了。

**Google Photos uploader CLI** 需要配合 Goole Cloud Platform 平台的 API 才能使用，简易步骤如下：

### 安装

macOS：_brew install gphotosuploader/tap/gphotos-uploader-cli_

Linux：[下载页面](https://github.com/gphotosuploader/gphotos-uploader-cli/releases/tag/v1.0.5)

### 获取 API

确保已登录要上传至 Google 相册的账号：

1. 进入 [Google Cloud Platform](https://console.cloud.google.com/projectcreate) 新建项目，可取名类似 gphoto
2. 激活 [Google Photos Library API](https://console.cloud.google.com/apis/library/photoslibrary.googleapis.com)
3. 创建 [OAuth 同意屏幕](https://console.cloud.google.com/apis/credentials/consent)，User Type 选择外部，新页面需要名称和图标
4. 创建 OAuth 2.0 客户端 ID，获取 ClientID 和 ClientSecret，应用类型选择其他

![](https://static2.appinn.com/images/202002/screenshot-2020-02-28-at-16-17-20.jpg)

![](https://static2.appinn.com/images/202002/screenshot-2020-02-28-at-16-24-25.jpg)

### 配置 **Google Photos uploader CLI**

在终端运行：**gphotos-uploader-cli init** 创建配置文件，默认保存在 ~/.gphotos-uploader-cli/config.hjson，修改 config.hjson 文件里面的：

- ClientID
- ClientSecret
- account
- sourceFolder

account 为你的 Google 相册账号。sourceFolder 为想要上传的照片文件夹路径。

### 确认授权

配置文件修改之后，运行：**gphotos-uploader-cli auth**，进行授权确认，此过程需要登录 Google 账号，唯一需要注意的是会出现此应用不安全的提示，选择继续前往即可。

![](https://static2.appinn.com/images/202002/ask_for_application_verification.jpg)

最终获得确认页面：

![](https://static2.appinn.com/images/202002/final_confirmation.png)

关闭窗口即可。

### 上传

终于到了上传步骤，只需要将照片保存在上面设置的 sourceFolder 目录，然后运行：**gphotos-uploader-cli push** 即自动开始上传。

很快，就能在 Google 相册中看到上传的照片了。更多详见 [GitHub](https://github.com/gphotosuploader/gphotos-uploader-cli) 页面。

## Topics

**分类目录:** [macOS](https://www.appinn.com/category/mac/?output_format=md)

**标签:** [Google Photos](https://www.appinn.com/tag/google-photos/?output_format=md), [Google 相册](https://www.appinn.com/tag/google-%e7%9b%b8%e5%86%8c/?output_format=md), [twp](https://www.appinn.com/tag/twp/?output_format=md), [命令行](https://www.appinn.com/tag/%e5%91%bd%e4%bb%a4%e8%a1%8c/?output_format=md), [开源](https://www.appinn.com/tag/%e5%bc%80%e6%ba%90/?output_format=md)