+ Start a Discussion
emmadiemmadi 

User-Agent OAuth Authentication Flow:Status Code 302

we want to integrate Salesforce with Java application using Rest API for authentication we want to use User-Agent OAuth Authentication dont want to expose the Username and password 


                string URI = 'https://cs1.salesforce.com/services/oauth2/authorize?response_type=code&' + 'client_id=' + ConsumerKey + '&' + 'client_secret=' + clientId + '&' + 'redirect_uri=' + redirectUri;
       
  HttpRequest req = new HttpRequest();
                req.setEndpoint(URI);
                req.setMethod('GET');
                Http http = new Http();
                HTTPResponse res = http.send(req);
                System.debug('response is'+res+'body is'+res.getBody ()+'*** After Authentication...');

I am getting Status Code 302  and redirecting to URL.

My question how can we use Oauth autentication without username and password Java to Salesforce inegration? 

Wade WegnerWade Wegner
A few things for you to take a look at:

1. Review the Understanding Web Server OAuth Flow (http://www.salesforce.com/us/developer/docs/api_rest/Content/intro_understanding_web_server_oauth_flow.htm)document and check for any simple mistakes.

2. Instead of using cs1 use https://login.salesforce.com/services/oauth2/authorize.

3. Double (and triple) check your consumer key and callback url and make sure they're the same as in your Connected App.

4. You can try to url encode your redirect uri.

5. Check and ensure you've given the appropriate credentials for OAuth in the Connected App.

I hope this helps!