I am attempting to use the immediate parameter to check if a Salesforce user has already approved access when going through the Web Server OAuth Flow as documented on OAuth 2.0 Web Server Authentication Flow. My reasoning for this is that I do not want the login or consent prompts to appear so I can reject access if they have not already approved.

Once the callback page is hit, I am always receiving the parameter error=immediate_unsuccessful even if the user has approved the application before and is logged in.

I have attempted to check this via a customised Google OAuth 2 Playground and setting immediate=true or immediate=false to the end of the authorize endpoint. On =false, the consent prompt shows and then you can grant access. On =true, this returns the same error as listed previously.

The Connected App that has been set up has api and refresh_token as the available scopes, users are able to authorize themselves and there are no ip restrictions set. The client id and secret from this app is then passed into the OAuth 2 Playground.

Below is a brief example on how my proper application redirects to the auth url using Java and the Google OAuth client library. We initially authorize the client without the immediate and then later on call the same code with immediate=true (shown in example)

AuthorizationCodeFlow authorizationCodeFlow = new AuthorizationCodeFlow.Builder(BearerToken.authorizationHeaderAccessMethod(), 
            new GenericUrl("https://login.salesforce.com/services/oauth2/token"),
            new ClientParametersAuthentication(CLIENT_ID, CLIENT_SECRET), 

    AuthorizationCodeRequestUrl authUrl = authorizationCodeFlow.newAuthorizationUrl()
        .setScopes(ImmutableSet.<String> of("api", "refresh_token"))
        .set("prompt", "consent")
        .set("immediate", "true");



  • Are there any settings that I may have missed in Salesforce that would alleviate the error?
  • Does the immediate setting even work?

closed as off-topic by Adrian Larson, Himanshu, Mohith Shrivastava, Sebastian Kessel, Adam Spriggs Aug 11 '16 at 19:22

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions not specific to Salesforce are off-topic here, but can be asked on Stack Overflow." – Adrian Larson, Himanshu, Mohith Shrivastava, Sebastian Kessel, Adam Spriggs
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Is this on a Visualforce Page? Can you please edit your post to include any relevant code? Thanks! – Adrian Larson Aug 11 '16 at 15:12
  • @AdrianLarson This is for the OAuth flow and is not related to the immediate attribute on Visualforce (commandLink and commandButton). I have included a Java example when redirecting the user to the authorize endpoint. The issue can be replicated on the OAuth Playground link. – Gary Marsh Aug 11 '16 at 15:39
  • This question seems like it belongs on Stack Overflow. It is only peripherally related to Salesforce. – Adrian Larson Aug 11 '16 at 15:40