I am developing a location based recommendation service and will be using Eventbrite API for the same. The eventbrite API uses OAuth for basic authentication. When registering the application with Eventbrite API, the application is given a application key and we have to enter a redirect URI that the user will be redirected to after they approve or deny authorization for the app. the problem is that I am not able to set the redirect URI correctly. I have tried various combinations such as http://localhost/, http://10.0.2.2:5554/, http://10.0.2.2/ or some random URI like myapp://oauthresponse but none of them seem to work.
My code is listed below:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myWebView = (WebView) findViewById(R.id.webview);
myWebView.getSettings().setJavaScriptEnabled(true);
URL url;
try {
url = new URL("https://www.eventbrite.com/oauth/authorize?response_type=code&client_id=<<my application id>>");
myWebView.loadUrl(url.toString());
String code = url.getQuery().toString();
System.out.println(code);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
What I want is that the user be redirected to my application once he authenticates with the API and if the authentication is successful the URL will be sent back with the value of the code. I want to retrieve the code value and store it for future purposes.
Please help!
Thanks in advance.
-
Anushree



