function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AshiAshi 

OAuth.2.0 Username-Password Flow

Hi,

 

I found about the OAuth.2.0 Username-Password Flow at : https://login.salesforce.com/help/doc/en/remoteaccess_oauth_username_password_flow.htm .

 

I want to implement this for a mobile application using JQuery ajax call.  I tried below, but it does not work for me:

$.ajax({
   type:"POST",
     url: loginUrl+'services/oauth2/token?'
                 +'&grant_type=password&client_id='+escape(clientId)
                 +'&client_secret='+escape(clientSecret)
                 +'&username=user&password=mypwd',                
     success: function(){
        alert("Hello");
      }
   });

Can someone help me with a code samlpe for this.

 

Thanks.

mobillemobille

hi ashi,

yoi should pass security_key with the pass word. try this

$.ajax({
   type:"POST",
     url: loginUrl+'services/oauth2/token?'
                 +'&grant_type=password&client_id='+escape(clientId)
                 +'&client_secret='+escape(clientSecret)
                 +'&username=user&password=mypwdsecurity_key',                
     success: function(){
        alert("Hello");
      }
   });