0

I'm trying to get an access_token and a refresh token for a connected app. I managed to get either the access_token and a full access to the API, or an access_token and a refresh_token, but without the ability to fetch opportunities and other data.

I'd like to get the full authorization, plus a refresh token.

Here is the POST request to get the full auth without a refresh token:

url = instance_url + '/services/oauth2/authorize?' 

params = {
  redirect_uri: "http://example.com/salesforce/login",
  client_secret: secret_key,
  client_id: client_key,
  code: code,
  scope: "full",
  response_type: "token",
  grant_type: "refresh_token"
}

Here is the POST request to get the refresh token and the access_token without the full authorization:

url = instance_url + '/services/oauth2/authorize?' 
params = {
  redirect_uri: "http://example.com/salesforce/login",
  client_secret: secret_key,
  client_id: client_key,
  code: code,
  scope: "refresh_token",
  response_type: "token",
  grant_type: "refresh_token"
}

How can I solve this ?

1

Specify both scopes:

  scope: "refresh_token full",

The scope parameter is a space-delimited list of scopes you would like to request. You can specify as many scopes as you need to be as granular as you'd like.

The parameter needs to be encoded using the method outlined in this help topic.

  • Already tried this, I receive: The value of the "scope" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information. – Graham Slick Oct 22 '17 at 18:41
  • @GrahamSlick Depending on your library, you might need to "escape" the space manually, as outlined in the documentation. Try scope: "refresh_token%20full" instead. – sfdcfox Oct 22 '17 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.