Apps Script Setup

This tutorial assumes you've installed CrosKeys by CrosExperts and have an active CrosKeys Pro membership.

Before you can run Apps Scripts via CroScripting, there's a bit of setup required.

1. Authorize

The first thing you have to do is give CroScripting consent to run the Scripting and Downloads APIs.

This is done when you first press the CroScripting button in the Options page.

When that's complete, the new scripting tab will open and you can now proceed with Cloud setup.

2. Google Cloud Project

For your security, our servers are only used for authentication. To run apps script, you must create your own google cloud project (GCP) which is only accessible by YOU.

If you have a pre-existing GCP that you'd like to use, skip this part.

To create a free GCP, go to the Cloud Console website and press the "Select a Project" button in the top left and click "New Project (See example gif).

When that's created, you should see a project number and project id.

Save the project number (we'll need it to create Apps Scripts later) then move on.

3. Give Apps Script Permission to Run

Next you have to enable the Apps Script API for your GCP. This will allow CroScripting to perform its magic.

Press the menu button and navigate to the Enabled APIs & Services option.

There, press the + button at the top, then search for the "apps script API."

When you find it, press "Enable."

Now in order for us to run Apps Scripts from CrosKeys, we'll need proper credentials.

4. Create an OAuth Screen

Navigate to the APIs & Credentials page and create an oauth screen.

Once you've filled in your personal email address, press "Save and Continue" a few times to proceed.

5. Create Credentials

When you're done, Google will push you to create your credentials. Here, you need to paste the CrosKeys redirect link ( https://akiaafoeijpibmbbfaebhkhccepbdgfi.chromiumapp.org/ )

If you have your project number written/copied somewhere (CrosKeys Clipboard Manager would come in handy here), you can now close the scary Cloud console!

Head to the CroScripting "Apps Script" page and enter your client id and secret. Next, select the scopes you want to access with your apps scripts and press "Confirm Selection."

Select which account you want CroScripting to access, then give it permission.

If you're successful, you'll get a notification from CrosKeys, and the CroScripting window should now look like this:

Now you're all set to create Apps Scripts!

6. Create an Apps Script

In the CroScripting editor, let's create a sample apps script for translation. 

Name your script "Translate" then enter the following code as the function body.

function translate(userInput, originalLang, targetLanguage) {  var translation = LanguageApp.translate(String(userInput), String(originalLang), String(targetLanguage));  return (translation)}

Then, press "Save Script."

After uploading to the cloud, you should see text saying your Script's been created. But before we can run it, we have to connect it to your GCP. Remember that Project number from step 2? It's time to use it.

If your Chromebook's main account is the one signed into CroScripting (step 5), then you can press the "Open Apps Script IDE" button to connect your GCP. Otherwise, use this link then switch to the proper account.

You should see an apps script project called "CroScripting" here.

Press it, and the sample script (Translate) we created should be here.

Awesome! Now to run this sample script, press the Project Settings button on the left and scroll down till you come to the "Google Cloud Platform (GCP) Project" section. 

Press the "Change Project" button, paste in your saved Project Number (from step 2), and click "Set Project."

7. Final Steps

Now activate CrosKeys and run the Update Apps Script ("au") command to save everything. For future reference, you should run the "au" command whenever you make changes to your apps scripts.

Once you're updated, run the CroScripting ("x") command and you should see our lone Translate script popup. Click it, then enter the text you want translated, as well as a source and target language.

If you've set everything up as instructed, the translation will go through!

Congrats, you're now ready to create and run Apps Scripts from anywhere using CrosKeys!

There's plenty more you can do with it, so be sure to check out our blog and youtube channel for more information.

And keep on getting more out of your Chromebook!