+Dev

On Mon, Sep 17, 2018 at 8:41 AM, Shakila Sasikaran <[email protected]> wrote:

> Hi Aman,
>
> You can use the filter mediator [1] for this conditional use-case. Please
> check the example below. Here, we get the field values from the user input
> and do the check with filter mediator.
>
> <property expression="json-eval($.client_id)" name="clientId"/>
> <property expression="json-eval($.clientSecret)" name="clientSecret"/>
> <property expression="json-eval($.grantType)" name="grantType"/>
> .......
> <filter source="boolean($ctx:clientId) and boolean($ctx:clientSecret) and
> boolean($ctx:grantType)" regex="true">
>     <then>
>         <!-- do facebook API related operation -->
>     </then>
>     <else>
>         <!-- do google API related operation  -->
>     </else>
> </filter>
>
> [1] https://docs.wso2.com/display/EI630/Filter+Mediator
>
> Thanks
>
> On Fri, Sep 14, 2018 at 1:20 PM, Aman Singh <[email protected]>
> wrote:
>
>> Dear Shakila,
>>
>> I have created a sample WSO2 project which generates an access token. For
>> first I tried to generate access token for sample Google API. For
>> generating access token for Google API we need (client id, client secret,
>> redirect uri, code, url, grant type) for our sample google app we
>> registered. I have a Java class which I am calling in my 'sequence', and
>> that Java class uses all the required (client id, client secret, redirect
>> uri, code, url, grant type) and generates Access token and return to my
>> sequence, which I am printing with a simple Log. I am successfully able to
>> generate token.
>> I have created a simple 'local-entries' xml where I enter all the
>> required(client id, client secret, redirect uri, code) as below:-
>>
>> LocalEntryGoogle.xml :-
>> <localEntry key="LocalEntryGoogle" xmlns="http://ws.apache.org/ns/synapse
>> ">
>>     <list>
>>         <client_id>value</client_id>
>>         <client_secret>value</client_secret>
>>         <url>value</url>
>>         <code>value</code>
>>         <grant_type>value</grant_type>
>>         <redirect_uri>value</redirect_uri>
>>     </list>
>> </localEntry>
>>
>> In my Java class I call this local-entries file and use all values to
>> generate access token and return that back to sequnece
>>
>> MySequence:-
>> <sequence name="MySequence" >
>>      <class name="com.rocky.GetAccessToken"/>
>>      <log level="custom">
>>               <property expression="get-property('AccessToken')"
>> name="AccessToken"/>
>>      </log>
>> </sequence>
>>
>> Now, I also want to try this for FaceBook, but facebook only uses (client
>> id, client secret, grant type) to generate access token. If I do this by
>> making separate local-entry file for Facebook and then running application
>> individually for Facebook or Google I am able to generate access toke.
>>
>> But what I want to do is I wish to take input from user in say key value
>> pair, like if user want to generate access token for Google(client id,
>> client secret, redirect uri, code, url, grant type), user will provide all
>> details in key-value pair or if he want for Facebook(client id, client
>> secret, grant type), he will only provide those 3 , and then depending on
>> type of information provided by user we can initiate one flow, like some
>> choice condition.
>>
>> Can you help me in with how to write condition which will determine which
>> flow should run in our 'sequnece' depending on input. Can you also tell me
>> which mediator I can use to take input from user.
>>
>> Thank you,
>> Aman
>>
>>
>>
>
>
> --
> Shakila Sasikaran
> Software Engineer
> Mobile :+94 (0) 77 526 6848
> [email protected]
> WSO2, Inc.
> lean . enterprise . middleware
> http://www.wso2.com/
>



-- 
Shakila Sasikaran
Software Engineer
Mobile :+94 (0) 77 526 6848
[email protected]
WSO2, Inc.
lean . enterprise . middleware
http://www.wso2.com/
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to