Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

I'm trying to get access to salesforce report data using OAuth token. Some time ago it worked fine, I used the OAuth token as the session ID.

...

URL remoteFile = new URL(instanceURL + "/" + reportId + "?export=1&enc=UTF-8&xf=csv");

URLConnection fStream = remoteFile.openConnection();

fStream.setRequestProperty("Cookie", "sid=" + accessToken);

...

But it doesn't work, every time I try to access the URL it returns an HTML page which corresponds to the login page. Is there any way I can access report data (not meta-data) using the OAuth access_token?

Thanks.

1 Answer

0 votes
by (32.1k points)
edited by

In order to use the token with such a URL, you need to set the scope parameter to include web:

web Allows the ability to use the access_token on the Web.

The oAuth User Agent Flow documentation details where the scope parameter is specified.

Become a salesforce certified administrator by going for Intellipaat’s Salesforce online training!
 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...