Mule ESB Facebook Connector: store and restore accesstoken - mule-studio

I'm working with the Mule ESB 3.4 and the IDE MuleStudio 3.4.0 on a flow to login to facebook, using the facebook-cloud-connector. The auth works fine, but now I'm looking for a way to re/store the generated accesstoken I recieve from facebook via:
<facebook:oauth-callback-config domain="localhost" localPort="7081" remotePort="7081" />
I currently use the following snippet to persist the auth-data to disk:
<facebook:oauth-store-config objectStore-ref="_defaultUserObjectStore">
The question is: How can I store the information, an objectstore, into a database?
Cheers!
EDIT: For everyone who wants struggled on the same point. I've create a Class which inherits the ObjectStore class from the mule api. After that, I've overriden the Store method, which gets called, when an accesstoken is requested by the mule-facebook-connector.

Related

WSO2 API manager returns binary response

I am very new to WSO2 API manager and trying out my very first simple restful api. which returns json response and has no security since it is an internal api.
I installed WSO2 API manager locally and trying to call the rest api on my dev server which uses http and no security as I mentioned earlier.
Here is how my get url looks like:
and here is my url looks like for production and sandbox environment:
I don't have any message mediation enabled.
I went to the API store and created a trial application (so that I can get the access token. Eventhough, my dev environment api has no security, I was reading that for throttling and other purpose, I need to pass bearer token to the WSO2 api OR it will reject the request.)
When I am trying to consume the api, I get the following binary message.
Is there any way I can see the proxy log on WSO2 server so that I can see the request and its header sent to my dev server?
How can I fix this binary response to get the proper json response?
I searched all over and can't find solution to it.
You can use below steps on WSO2 ESB or APIM to enable Wire Logs.
Uncomment below line in /repository/conf/log4j.properties
log4j.logger.org.apache.synapse.transport.http.wire=DEBUG
Restart Server.
Source - http://lakshanigamage.blogspot.com/2015/03/how-to-enable-wire-logs-in-wso2-esbapim.html

JBoss Fuse Integration from HTTP with POST parameters

Firstly, apologies as I'm a bit of an ESB newbie.
I'm trying use Fuse Integration in Red Hat JBoss Developer Studio to create a simple integration between an HTTP URL with some POST parameters (login, password, etc) to an output file.
I'm thinking I'd need to carry out the following steps...
Do a HTTP login to a specified URL (passing login, password as parameters)
Capture authentication details - cookie file? - to reuse for the next step
Do a HTTP fetch from the same URL
Write the fetched data to a text file
A colleague's making some progress with this using Mulesoft but I'd like to see if this is a simpler exercise in JBoss.

How to connect GitHub API using console application and oAuth

I have windows console application that needs to interact with GitHub API using octokit.net. The first step is to register application with GitHub. On the registration page i have to provide Homepage Url and Authorization callback Url
For console application what would be the values for these two fields? I really dont want to connect GitHub using userid, password

Keycloak security for Spring base rest apis

I want to integrate keycloak security features to my spring boot based rest apis.
I am using KeyCloak 1.3.1 Final.
Now this is pure rest based api and am doing my testing through postman
I have got my rest api secured and when i try to access it do asks me for authorization, but am not able to execute my request. basically am locked out of my api.
I will quickly list out things that I have already done
Created a spring boot rest api and tested it. It works fine.
Modified my gradle for KeyCloak and configured it as per this document
Configured my keyCloak for the "bearer only" application
I tried to generate access token, but I was not able to. Therefore I created another Client in keycloak with "confidential" and used this client to generate the access token (both the clients were pointing to same application. Am not sure if this is correct)
With this access token, I am trying to make api call but am getting 401
Again am using this document.
I am new to both keycloak and spring.
So what I want to ask here is how can we generate the access token for testing a rest api in a scenario like one which is here.
Any useful resource on KeyCloak that can help me out here. As of now I dont have a clue as to where the problem is? Is it with my api or with how I have configured the KeyCloak.
Also since I am new to spring and I just could not found a decent document on how to configure cloak for spring boot. If you can help with that as well.
Moving further on this I was informed on the KeyCloak mailing list that spring boot adapter only supports basic authentication, and so I decided to incorporate the spring security adapter itself.
I did that and when am running the application and providing creds am still not able to make it work. However something interesting is happening. I am being redirected to http://127.0.0.1:8090/sso/login
I double checked it and that is not the redirect url i have provided.
???
Any idea why?
(Once again am new to it and learning about spring and security on way through this project. So please bear with me.)
So after spending quite a good amount of time and getting some help from keycloak user list here is how i got it to work.
Use Spring Security instead of spring boost security adapter (as I have already mentioned in the the edit, boot adapter is only for basic authentication)
There documentation does a decent job of explaining out everything else refer to that.
I am still testing the whole thing and will document it out for future references.

Accessing REST service after login within browser using oauth2 and spring security using java config

I have implemented Oauth2 using sparkl2 app. I am using spring-security as described in the sparkl2 app using java config. I can successfully get auth token using curl and i can invoke web service using curl.
My question is
How I can access my REST service within the same browser after login into my application? I am not sure what I am missing here?
Let me elaborate my question in more details. The way browser keep session after login and we can access any protected resource in the application, what is the best way to implement so that I can test my REST api from browser
spring security keeps it in session. Session id is stored in browser cookie, so its passed with each request to your service. Then spring security should take it and check if specific session(with user logged in) is allowed to hit this particular url.
I would start with configuring secure paths in your java config:
http.authorizeRequests().antMatchers().hasAnyRole(...)
or some other method instead antMatchers.
you probably have to log in user into spring security on some oauth callback, something like:
Authentication auth = new UsernamePasswordAuthenticationToken(user, null, authorities);
SecurityContextHolder.getContext().setAuthentication(auth);