You need to sign in to do that
Don't have an account?
Where do you get "code"
In the Force.com REST API Developer's Guide, there is a section of code on page 7 that can be seen below. I can see/figure out where all the variables are set besides the following. "post.addParameter("code",code);" Where or how do you get 'code'?
I am trying to Salesforce REST to work on an Android and am stuck. If you have any tips on the proper way to authenticate I would be very appreciative.
initParams={
@WebInitParam(name="clientId",value=
"3MVG9lKcPoNINVBJSoQsNCD.HHDdbugPsNXwwyFbgb47KWa_PTv"),
@WebInitParam(name="clientSecret",value="5678471853609579508"),
@WebInitParam(name="redirectUri",value=
"https://localhost:8443/RestTest/oauth/_callback"),
@WebInitParam(name="environment",value=
"https://na1.salesforce.com/services/oath2/token") }
HttpClienthttpclient=newHttpClient();
PostMethodpost=newPostMethod(tokenUrl);
post.addParameter("code",code);
post.addParameter("grant_type","authorization_code");
/**ForsessionIDinsteadofOAuth,use"grant_type","password"*/
post.addParameter("client_id",clientId);
post.addParameter("client_secret",clientSecret);
post.addParameter("redirect_uri",redirectUri);
I think OAuth 2.0 Username-Password Flow explains what you're trying to do. The code fragment on p7 of the developer guide is part of the web server flow, itself described in more detail in Getting Started with the Force.com REST API.