Bad Grant Type error for hubspot API access Token


I am trying to get access token as per the developer forms but everytime i bumped into this error .

here's how i am trying to get the access token . Any idea what am i doing wrong ?

Auth_token_url = ''

headers_api = c(``Content-Type`` = 'application/x-www-form-urlencoded;charset=utf-8')

parameters = list(
grant_type= 'authorization_code', client_id``= 'xxxxxxx',``client_secret = 'xxxx',
redirect_uri` = '',`code`` = 'xxxxx')

GetToken <- httr::POST(url = Auth_token_url, httr::add_headers(.headers=headers_api), body=parameters, httr::authenticate('client_id', 'client_secret') )

GetToken_text=content(GetToken, "text")



"BAD Authorization Code" issue

Hi @pan999, while I don't know much about using R to generate access tokens, that message from HubSpot's servers means that your grant_type parameter isn't present or are malformed. Taking a look at the httr docs, I'd try to make the request as simple as possible and try work back from there. This section seems to be what you're looking for:

I'd also try checking out this post I found about OAuth here: