Skip to main content
Question

Requesting Access Token via API

  • May 22, 2025
  • 1 reply
  • 3 views

Forum|alt.badge.img

Hi,

My use case here is to automate the extraction of files from an SFTP and store it into one of my Box folders.

I tried to first authenticate myself using "client_id" and "client_secret" with grant_type = client_credentials, however, I get an error -  Invalid grant_type parameter or parameter missing

Can someone help me understand what am I doing wrong here?

Below is the code 

import requests


url = "https://api.box.com/oauth2/token"

h = {
"Content-Type":"application/x-www-form-urlencoded",
}
params = {
"client_id":"sdfsdfsdfsdfsd",
"client_secret":"sdfsfsdfsdfsdfsdfsdf",
"grant_type":"client_credentials"
}

r = requests.get(url, headers=h, params=params).json()

print(r)

1 reply

Forum|alt.badge.img

Hello Yatish, 

It looks like you're trying to use client credentials grant, which requires 5 parameters. However, you only have 3 here. Please review our documentation for a sample. 

Best,

Kourtney, Box Developer Advocate