I'm referring https://dev.fitbit.com/apps/oauthinteractivetutorial link for getting access token in Android App.
Step 1:
Here I have hard coded registered app details.
String urls = "https://www.fitbit.com/oauth2/authorize?" +
"response_type=code" +
"&client_id=228K7X" +
"&expires_in=2592000" +
"&scope=profile%20settings%20weight" +
"&redirect_uri=http://www.google.com/" ;
From this link I should get Code.If I copy Past this in browser I'm getting code like this
http://www.google.com/?code=e800eef2374bd6c1f5cc5e8dab65d4d4bff60406#=
I've tried like below in android code ,But not getting expected result.Can any one help me for this?
URL url = new URL(urls);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.connect();
InputStream inputStream = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(inputStream));
This is Fixed.Find answer below,I'm using Webview
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
String urls = "https://www.fitbit.com/oauth2/authorize?" +
"response_type=code" +
"&client_id=228K7X" +
"&expires_in=2592000" +
"&scope=profile%20settings%20weight" +
"&redirect_uri=http://www.google.com/" ;
Log.i(TAG," urls ? "+urls);
webView.loadUrl(urls);
webView.setWebViewClient(new WebViewClient(){
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
Log.i(TAG," onPageFinished ? "+url);
}
});