Kevin, So my SF guy is back from vacation.
I'm trying to convert the java example to PB. I'm having trouble figuring out how to set this up, as far as the redirecturi fits into the PB call. Is the redirect something I need to set up locally? Am I calling it correctly in PB?
Thanks
Dennis
Here is the Java:
/*
01 initParams = {
02 @WebInitParam(name = "clientId", value = "3MVG9lKcPoNINVBJSoQsNCD"),
04 @WebInitParam(name = "clientSecret", value = "5678471853609579508"),
05 @WebInitParam(name = "redirectUri", value =
06 "https://localhost:8443/RestTest/oauth/_callback"),
07 @WebInitParam(name = "environment", value =
08 "https://login.salesforce.com/services/oauth2/token") }
09
10 HttpClient httpclient = new HttpClient();
11 PostMethod post = new PostMethod(environment);
12 post.addParameter("code",code);
13 post.addParameter("grant_type","authorization_code");
14
15 /** For session ID instead of OAuth 2.0, use "grant_type", "password" **/
16 post.addParameter("client_id",clientId);
17 post.addParameter("client_secret",clientSecret);
18 post.addParameter("redirect_uri",redirectUri);
*/
------------------------------------------------------------------------------------------------------------------------------------
Here is my PB code:
integer rc
oauthclient client
tokenrequest request
tokenresponse response
string accesstoken
request.clientid = 'xxxxxxxxxxxxxxxxxxxxxx'
request.clientsecret = 'xxxxxxxxxxxxxxxxxx'
request.granttype = 'client_credentials'
request.method = 'POST'
request.setheader('redirectUri', 'https://localhost:8443/RestTest/oauth/_callback')
request.tokenlocation = "https://xxxxxx.salesforce.com/services/oauth2/token"
client = create oauthclient
rc = client.accesstoken(request, response)
destroy client
accesstoken = response.getaccesstoken()
integer li_rc
oauthclient lo_client
tokenrequest request
tokenresponse response
string ls_accesstoken, ls_type, ls_desc, ls_uri, ls_state
try
request.SetHeader ( "User-Agent", "Appeon test" )
request.clientid = '3MVG9lKcPoNINVBJSoQsNCD'
request.clientsecret = '5678471853609579508'
request.granttype = 'client_credentials'
request.method = 'POST'
request.setheader('redirectUri', 'https://localhost')
// request.tokenlocation = "https://login.salesforce.com/services/oauth2/authorize"
request.tokenlocation = "https://login.salesforce.com/services/oauth2/token"
lo_client = create oauthclient
li_rc = lo_client.accesstoken(request, response)
IF li_rc = 1 AND response.getstatuscode() = 200 THEN
ls_accesstoken = response.getaccesstoken()
mle_response.text = ls_accesstoken
ELSE
response.gettokenerror(ls_type, ls_desc, ls_uri, ls_state)
mle_response.text = String(response.getstatuscode()) + ": " + ls_type + " - " + ls_desc
END IF
catch(runtimeerror re)
MessageBox("RuntimeError", re.getmessage())
finally
IF IsValid(lo_client) THEN
destroy lo_client
END IF
end try