Brian Thompson 2 Posted September 28, 2017 Share Posted September 28, 2017 I am trying to build a connector using Scribe Fast Connector Framework.I have API calls to the external system validated using the free Postman application.Using the RestSharp.RestRequest class method I have not able to retrieve the token.Any ideas Link to comment Share on other sites More sharing options...
Nate Keefe Posted September 28, 2017 Share Posted September 28, 2017 Hi Brian, Our documentation has samples for creating an authentication call in the ConnectionConfiguration() method: https://dev.scribesoft.com/en/sdk/fast_framewrk/simple_conn/sc_authentic... Let us know if you think this is not helpful for your use-case. If that's the case, the Postman scripts and your ConnectionConfig() code will be helpful to shed some light on your exact use-case. Best, Nate ______ Help others find useful posts by selecting the best answer to your question. Click "Like" to highlight great replies. Link to comment Share on other sites More sharing options...
Brian Thompson 2 Posted September 28, 2017 Author Share Posted September 28, 2017 I selected "Basic" authentication when using the Fast Connector Framework Wizard. The call in Postman to get the token had the following properties: Method = "POST" URL=https://spm.ibmcloud.com/services/login Header = (Key = Content-Type, Value = "application/json") Body = { "email":"XXXX", "password":"ZZZZ" } This call returns a JSON formatted object containing the token needed to make additional calls to the application. Link to comment Share on other sites More sharing options...
Nate Keefe Posted September 29, 2017 Share Posted September 29, 2017 Hi Brian, You'll probably want to use the OAuth option so you can reuse the token. You'll need to add properties in the ConnectionInfo class for your Email and Password: public class YourConnectorConnectionInfo : JsonHttpConnectionInfoBase { // USE FOR OAUTH 2.0 public string email { get; set; } [PasswordPropertyText(true)] public string password { get; set; } [PasswordPropertyText(true)] public string token { get; set; } } Then you'll want to create classes for the input and output Json on the authentication call (here's an example how: https://www.youtube.com/watchv=5vwzB5Zm6AA). Then you can add you Http POST to the ConnectionConfigure() method. Here's a lite example to get you going: protected override Func ConnectionConfiguration() { //Used for OAuth string LoginUrl = "https://spm.ibmcloud.com/services/login"; var myToken = this.Connection.Configure("POST", LoginUrl) .ToHeader("Content-Type", "application/json") .ConnectionInfoToBody .FromResponseToContext("Authorization", (rA => "Bearer " + rA.token)) .ConnectionInfoToBaseUrl(info => "https://spm.ibmcloud.com/....") .End(); return myToken; } I hope this helps you get going. Best, Nate ______ Help others find useful posts by selecting the best answer to your question. Click "Like" to highlight great replies. Link to comment Share on other sites More sharing options...
Brian Thompson 2 Posted September 29, 2017 Author Share Posted September 29, 2017 Nate, I am struggling here. I appreciate the help, but I dont know what to replace .ConnectionInfoToBody with. Can you help Thanks, Brian. Link to comment Share on other sites More sharing options...
Nate Keefe Posted September 29, 2017 Share Posted September 29, 2017 Hey Brian, Let's chat offline about this connector project so we can support you appropriately. Best, Nate Link to comment Share on other sites More sharing options...
Nate Keefe Posted September 29, 2017 Share Posted September 29, 2017 For other readers, ConnectionInfoToBody can be used to pass the values collected in ConnectionInfo (i.e. the Email and Password a user provides in the Scribe Connection UI) to set values in an Input Class (also Email, Password) that will later be serialized as JSONwhen Scribe performs the Http Post needed to Authorize Scribe. The response from the server will be saved in an additional ConnectionInfo class (like "token") and can be used later. Link to comment Share on other sites More sharing options...
Brian Thompson 2 Posted September 29, 2017 Author Share Posted September 29, 2017 Nate, Whenever you have time, I am available. Thanks, Brian. Link to comment Share on other sites More sharing options...
Manoj Chaurasia Posted January 14, 2019 Share Posted January 14, 2019 Hay Nate Can you lease explain .ConnectionInfoToBody line with code example. I tried to do .ConnectionInfoToBody("GET",(form) => form.BaseUrl, this.username, this.password) But its give us a error like No Overload for method ConnectionInfoToBody takes arguments. please help. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now