cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Body Content in Post Snap

jsmith141
New Contributor III

Hi,

This is a very novice question, but I am having trouble with a post request snap. This is just to authenticate with the RingCentral platform to receive a token for API consumption. I am able to successfully retrieve an access token when calling the oauth/token endpoint in Postman. The issue arises when I try to move this post call into SnapLogic. The call requires certain parameters to be passed through the body and I am not sure how to duplicate this in SnapLogic post snap. Please see the screenshot of the Postman call Body tab below.

image

I have created a basic account in SnapLogic to store the username and password and my post snap references that account. I am also aware that the credentials of a basic account can be accessed using the “Account.Username” and Account.Password" of the respective referenced account within the snap.

I am just not sure how to build out the body section in the “x-www-form-urlencoded” format as shown in the screenshot? The error I get back when validating this post snap is just a 400: Bad Request.

Any insight/help that anyone could provide would be greatly appreciated. Please let me know if additional information is needed to provide assistance.

Thanks,
James

48 REPLIES 48

redirect_uri is what is provided for SnapLogic to respond, in this case, it would likely be (in the rest account) https://elastic.snaplogic.com/api/1/rest/admin/oauth2callback/rest which redirects back to the base url for snaplogic to complete the next step of the auth. If you move to openAPI, you’ll replace rest with openapi. The REST OAuth2 Account documentation has it right at the top under Account Settings, it’s quite a bit confusing here because in this case you may not know what a POD is.

So if I understand you correctly, it sounds like there really should have been a place on the RingCentral side to add a redirect url? I did check several times because I expected there to be one as well, but never saw an option to enter a redirect url.

I added the redirect_uri argument to both the token and auth endpoint config sections using the uri you provided above.

When I click on the authorize button it looks like it is successful. A tab is temporarily opened and closed(it appears blank for its entire short duration on screen) and then the access token, refresh token, and Access token expiration are all populated. The first two are indicated to be encrypted and the expiration is a long numeric string.

However, when I go to validate the pipeline I get a long wait and then an error on the rest get snap which reads…

Failure: Error reading account, Reason: Snapi request failed: {“response_map”: {“error_list”: [{“message”: “Request from platform.devtest.ringcentral.com returned an error (response code: 400, response: {\n "error" : "unauthorized_client",\n "errors" : [ {\n "errorCode" : "OAU-251",\n "message" : "Unauthorized for this grant type"\n } ],\n "error_description" : "Unauthorized for this grant type"\n})”}]}, “http_status_code”: 500}

The only thing I can see is that it is possible that the client id and client secret are not being passed as expected by RingCentral (i.e. concatenated together as client_id+‘*’+client_secret and then the whole thing is base64 encoded). Does this account type take care of that in the background, or is the issue something else entirely? I do see in the error that there is an “Unauthorized for this grant type”, but I am successfully using that grant type in Postman.

Thanks,
James

I created a RingCentral account yesterday, but haven’t been able to get a Sandbox account up and running. I did get to the point in the provision where login takes place and I can share some screenshots there, but here’s the screenshot of my account on the SnapLogic side (it’s a REST OAuth 2 Account)
image
On the RingCentral side, you’ll want to set your application to be a 3-legged application with redirect_uri being the previously mentioned uri ( https://elastic.snaplogic.com/api/1/rest/admin/oauth2callback/rest ).
image
This will bring up a RingCentral login prompt for you to fill out with your (I believe) sandbox account, and then it should be able to get a token back from the token endpoint. Again, I haven’t been able to get a Sandbox account created through RingCentral, so I can’t validate this on my side.

Our OAuth2 Account will follow the Auth code flow semantics directly that they specify here. You’ll need to check the box at the bottom of the account that specifies Sending Client Data as Basic Auth header, that’s talked about in the “Step 3. Exchange auth code for access token” section. Once it authorizes properly, you’ll want to then check the box that says “Auto-refresh token” in our snap account configuration, as that will continually refresh the token behind the scenes so that you don’t have to perform the login screen piece any more.

I think I see what I need to do differently. On the RingCentral side, I don’t think I chose the 3-legged OAuth flow authorization code. So let me try to setup the way you have pointed out here. I am betting I will have to create a new app on the RingCentral side. I will get back with you on this post once I have done that.

Thanks,
James