How to automatically upload the daily NYT crossword to Dropbox

This guide will walk you through the steps to automatically upload the daily NYT to your personal Dropbox account so that it can be synced with devices like the Ratta Supernote e-ink tablet.

Throughout the course of this tutorial, you will create a Dropbox developer app, generate a Dropbox refresh token, and deploy a cron job to Render.com.

Please note that Render.com does charge for this service, but the fees should be extremely minimal (approx. $1/mo).


Step 0: Pre-requisites

  • A Dropbox account.
  • A NY Times puzzle subscription.
  • Enough technical know-how to access your computer’s terminal, make cURL requests, and access your browser’s developer console.
  • About $1 to spend per month.

Step 1: Create a Dropbox developer app

First, you need to create your own personal Dropbox developer app. Don’t worry, the app won’t be publicly available. It will just allow you to use Dropbox’s APIs to upload files.

Navigate to your App Console on the Dropbox Developer portal, and create a new app.

image

You will now configure your application.

For Step 1., choose Scoped access.

Screenshot from 2023-03-12 17-53-22

For Step 2., choose Full Dropbox.

Screenshot from 2023-03-12 17-53-34

For Step 3., enter something meaningful like NYT Crossword.

You may also have a Step 4. if your personal Dropbox account is linked to a business Dropbox account. If you see this step, simply choose the account which you want to create the app with.

Screenshot from 2023-03-12 17-53-55

Click Create app to finish.

On the next page, take note of your App key and App secret. We’ll need these multiple times in the future.

image

Navigate to Permissions and select the checkbox for files.content.write. This is because your app will need to be able to write to your Dropbox account in order to upload the daily NYT crossword.

Screenshot from 2023-03-12 17-55-28

Click Submit at the bottom to save your changes.

image

Step 2: Generate a Dropbox refresh token

In order to interact with the Dropbox’s API to upload files, we need to obtain a refresh token.

To do this, first you’ll need to authorize the app on your account and obtain an access code.

To generate an access code for you account, visit the following URL in your web browser, making sure to replace <app key> with your Dropbox app’s App key.

https://www.dropbox.com/oauth2/authorize?client_id=<app key>&token_access_type=offline&response_type=code

When you land on this page, you will see a warning about the kind of permissions the app will have on your account if you authorize it. Since this is your your Dropbox app with your App key and not anyone else’s, you can disregard this warning, and click Continue to move on to the next step.

image

The next step will be to approve the app for your account.

Like in step 1, you might be given an option to choose which account to authorize. If you only have one, disregard.

Approve your app and link it to your account.

image

On the next screen, you will see your access code. Copy this or write it down somewhere, you will need it in just a moment.

Note: You will need to do the next step within approximately five minutes, or the access token will expire. If the token has expired, simply open a new tab with that URL you generated a few steps ago and re-authorize the application.

image

Now let’s create a refresh token.

To do this, you’ll need to make the following cURL request from your terminal, being sure to replace some of the parameters with your own values you obtained in previous steps.

curl https://api.dropbox.com/oauth2/token \
    -d code=<access code> \
    -d grant_type=authorization_code \
    -d client_id=<app key> \
    -d client_secret=<app secret> | jq '.refresh_token'

Replace <access code> with the access code you just received.

Replace <app key> with your Drobox app’s App key from Step 1.

Replace <app secret> with your Drobox app’s App secret from Step 1.

image (9)

You should receive a response with a long string of characters. This is your refresh token. Write it down (without the surrounding quotes '...'), as you will need it later.

Since the NY Times crossword is a paid service, you will need to tell nytimes.com who you are when you make the web request.

Go to nytimes.com, and log in to your account with a paid puzzles subscription.

Next, open the developer console for your web browser.

image

Navigate to the console tab.

Type and enter ↴

document.cookie

This will return the full list of your unique cookies for nytimes.com. This tells nytimes.com who you are and which account to display on the webapge.

You only need a few of these, but it’s easier to just copy the whole list.

image (8)

Copy the entire output (without the surrounding quotes '...') and write it down somewhere, you’ll need this later.

Step 4: Deploy the cron job

Sign up for an account on Render.com if you don’t already have one.

Create a new Cron job project. A cron job is a task that runs at a specific time or times.

image

On the next screen, find Public Git repository and enter ↴

https://github.com/nathanbuchar/upload-daily-nyt-crossword-to-dropbox

This is the script that I’ve set up to do all the work for you. The code is open source, and can be audited if you have any security concerns.

Alternatively, you can fork the app to your own GitHub if you have one so that you have control over the code.

image

For the name, choose something like daily-nyt.

Choose Node for the runtime.

image

For schedule, enter ↴

5 2,3,22,23 * * *

This means the task will run four times every day. We run it four times a day to account for the one hour shift during daylight saving time (DST) and puzzle release times on weekdays vs weekends (10pm vs 6pm). We run the task 5 minutes past the hour to increase our confidence that the NYT Crossword has been published when the task runs.

UTC Eastern
02:05 UTC 10:05pm EDT
03:05 UTC 10:05pm EST
22:05 UTC 6:05pm EDT
23:05 UTC 6:05pm EST

And then for Command, enter ↴

node index.js

image

For Instance type, you should be more than covered with the cheapest tier, which at the time of this writing is the Starter tier.

Click Advanced. We now need to tailor the cron job for your specific Dropbox app and NY Times account.

You’ll need to create four environment variables ↴

Name Value
DROPBOX_APP_KEY Your Dropbox app’s App key from Step 1.
DROPBOX_APP_SECRET Your Dropbox app’s App secret from Step 1.
DROPBOX_REFRESH_TOKEN The refresh token you received from the cURL request in Step 1.
NYT_COOKIE Your nytimes.com cookie from Step 2.
DROPBOX_UPLOAD_PATH The path in your Dropbox folder where crosswords should be uploaded to. For the Ratta Supernote e-ink tablet, I’d recommend /Supernote/Document/Crosswords. Note: the path must start with a /.

image

Scroll down, and under Auto-Deploy, choose No. This is for your own security.

image

Scroll down and click Create Cron Job.

Step 5. Sit back and wait!

Your Cron Job should be all set up now and should automatically upload a PDF of the daily NYT Crossword to your Dropbox account every day! 🎉

Note that your nytimes.com cookie expires after one year. If your app stops working, it’s probably because you need to update the value of NYT_COOKIE.

If you run into any issues, please don’t hesitate to contact me.

Please consider leaving me a comment if you found any value in this guide. Take care!


Comments

Loading…