Skip to main content
Question

Authenticating with Box - Private Key works locally, but not when used in Github Workflow


Hello Box devs!

I’ve written a JS script that connects to box and uploads some files. When I run it locally, the script connects to Box using the following:
 

{  "boxAppSettings": {    "clientID": "value",    "clientSecret": "value",    "appAuth": {      "publicKeyID": "value",      "privateKey": "value",      "passphrase": "value"    }  },  "enterpriseID": "value"}

Locally this works and there is no problem. The issue is when the script is run by a Github Workflow for automation. In this case, no matter how I format the private key value, I get this response:
 

Error connecting to box: secretOrPrivateKey is not valid key material

This is the error I would get locally if the key was not being correctly loaded, due to an incorrect filepath or data type (not a string). I’ve confirmed this is not the case on github - the script finds the secret value, but using it produces this error.  I’m having a very tough time understanding why this code to move files to Box would work locally, but fail on Github Actions with the above private key error. 

The first thing I tried was different formattings of the private key (with the “\n” characters replaces with returns, no returns at all, etc). No variation of the private key string has made a difference to the github action results. Maybe there is some configuration I need to do in the Box dev console to ensure my private/public key pair can be used on Github?

 

Thanks for taking the time to read this. I appreciate your time and any advice you have!

 

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings