APIs & Integrations

Eli_A
Member

Get OAuth 2.0 Access Token and Refresh Tokens failue

Hi,

After the first step I am redirected to Hubspot and approve the app, I am then redirected by to my server and I am trying to create a server to server OAuth request to get access token and refresh token:

https://api.hubapi.com/oauth/v1/token?code=CODE&grant_type=authorization_code&client_secret=MY_CLIEN...

I followed the documentation from:

Get OAuth 2.0 Access Token and Refresh Tokens

POST /oauth/v1/token

However this request fails with error:
org.apache.oltu.oauth2.common.exception.OAuthProblemException: invalid_request, Missing parameters: access_token

Can you please help me to figure out what I am doing wrong? I am using java apache library to generate this request, it is getting a bit urgent for me and I don’t manage to solve this issue.

Thank you,
Eli

5 Replies 5
MPrasad9
Participant

Get OAuth 2.0 Access Token and Refresh Tokens failue

Hi @Eli_A, where you able to solve this issue?

0 Upvotes
Umar_Jamil
Member

Get OAuth 2.0 Access Token and Refresh Tokens failue

@Eli_A What is your redirect Uri and what error you are receiving?

0 Upvotes
MPrasad9
Participant

Get OAuth 2.0 Access Token and Refresh Tokens failue

Hi @Umar_Jamil, I have this same issue, I was able to authorize with url 

https://app.hubspot.com/oauth/authorize, But unable to get the token using the url 

https://api.hubapi.com/oauth/v1/token. Getting the below errror. Can you help me with this? Thanks
Error: 
invalid_request, Missing parameters: access_token

0 Upvotes
Eli_A
Member

Get OAuth 2.0 Access Token and Refresh Tokens failue

Hi Everyone,

Just for a reference, in case you are using Apache Oltu as an OAuth library:

At first I executed:

OAuthClientRequest oAuthClientRequest =
                    OAuthClientRequest
                        .tokenLocation(tokenLocation)
                        .setGrantType(GrantType.AUTHORIZATION_CODE)
                        .setClientId(clientId)
                        .setClientSecret(clientSecret)
                        .setRedirectURI(redirectUrl)
                        .setCode(code)
                        .buildQueryMessage();

Just replaced buildQueryMessage() with --> buildBodyMessage()

0 Upvotes
MPrasad9
Participant

Get OAuth 2.0 Access Token and Refresh Tokens failue

Hi @Eli_A @Umar_Jamil, Did you solve this issue? How to solve this issue?

0 Upvotes