OAuth2.0 authorization


#1

1.The URL exposed in Hubspot API docs for fetching campaign id’s for particular portal uses either ‘hapikey’ ‘Oauth access token’.
2.While getting campaign id’s with hapikeys gives proper response, but with Oauth token method gives response like :
{
“status”: “error”,
“message”: “This oauth-token (CJ-o5vODKxICEQMYxvKcASCJwdABKLCdAjIZACJrkER8XB1i2g_A11F6FYGYQP4iP9XM9Q) does not have proper permissions! (requires any of [email-access])”,
“correlationId”: “a7c591df-631f-4fad-adfe-2d512bf061bc”,
“requestId”: “1a97ab3e-373d-46be-8df9-276060d17bc9”
}
3.The URL used is : “https://api.hubapi.com/email/public/v1/campaigns/by-id?limit=100” with authorization as bearer and acccesToken in header.
4.Is there any relation of this with scope we mention in url while getting authorization_code ( “https://app.hubspot.com/oauth/authorize?client_id=a89d2989-2800-482f-99f0-bdf3a3251c2e&scope=contacts&redirect_uri=http://www.hubspot.com/”)
5.Because when tried using any other value for scope gives:
(“http://www.hubspot.com/?error=invalid_request&error_description=missing+or+invalid+scopes”)
6. What is significance of these scopes ?
7.Does it have any relation to permission while fetching data with OAuth token ?


#2

Hi @kajalna

The scopes provide access to specific sets of the APIs. For email access, you’d need to request the content scope, otherwise the access_token you get won’t have access to the Email Events API.


#3

Hi @dadams,

Thanks for quick response. We have added scope as “content” in the url but same behavior we are getting. Below are details about url used and response got from Hubspot.

Request :
https://app.hubspot.com/oauth/authorize?client_id=4f5c234f-6123-4ed1-8e2d-5064e84360e4&scope=content&redirect_uri=http://www.hubspot.com

Response:

Rather when we specify scope as “contacts” it provides code value. Appreciate your response. Thanks


#4

One more query, @dadams

We are facing issue while creating data for email events. We have created campaigns but getting blank response while fetching campaign data using
Request:

https://api.hubapi.com/email/public/v1/campaigns/by-id?hapikey=f169e42c-6d31-42c2-9abf-dae8b685061d&limit=3

Response:
{“hasMore”:false,“campaigns”:[]}


#5

Hi @dadams

Are there any updates here? Can you provide steps to create campaigns and email events for test data using https://app.hubspot.com so that we can fetch data using above mentioned url? Thanks


#6

Creating an email does not immediately create an email campaign, since the campaigns represent the email send, nopt the email content. You’ll need to send an email before you’ll have any campaigns.