THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
import java.net.URLEncoder; import org.apache.camel.builder.RouteBuilder; public class TutorialRouteBuilderGAuthRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { // Calback URL to redirect user from Google Authorization back to the web application String encodedCallback = URLEncoder.encode("https://gauth.example.org:8443/handler", "UTF-8"); // Application will request for authorization to access a user's Google Calendar String encodedScope = URLEncoder.encode("http://www.google.com/calendar/feeds/", "UTF-8"); // Route 1: A GET request to http://gauth.example.org/authorize will trigger the the OAuth // sequence of interactions. The gauth:authorize endpoint obtains an unauthorized request // token from Google and then redirects the user (browser) to a Google authorization page. from("jetty:http://0.0.0.0:8080/authorize") .to("gauth:authorize?callback=" + encodedCallback + "&scope=" + encodedScope); // Route 2: Handle callback from Google. After the user granted access to Google Calendar // Google redirects the user to https://gauth.example.org:8443/handler (see callback) along // with an authorized request token. The gauth:access endpoint exchanges the authorized // request token against a long-lived access token. from("jetty:https://0.0.0.0:8443/handler") .to("gauth:upgrade") // The access token can be obtained from // exchange.getOut().getHeader(GAuthUpgradeBinding.GAUTH_ACCESS_TOKEN) // The access token secret can be obtained from // exchange.getOut().getHeader(GAuthUpgradeBinding.GAUTH_ACCESS_TOKEN_SECRET) .process(/* store the tokens in context of the current user ... */); } } |
...