2017-06-01 7 views
0

Ich verweise https://dev.fitbit.com/apps/oauthinteractivetutorial Link für Zugriffstoken in Android App erhalten.Wie bekomme ich Code von https://www.fitbit.com/oauth2/authorize

Schritt 1:

Hier hart codiert registrierte App Details Ich habe.

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/" ; 

Von diesem Link I Code.If ich diese Vergangenheit in Browser kopieren bekommen sollte ich erhalte Code wie dieses

http://www.google.com/? code = e800eef2374bd6c1f5cc5e8dab65d4d4bff60406 # =


Ich habe in android Code wie unten versucht, aber nicht zu erwarten, immer result.Can jemand mir dies helfen?

     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)); 
+0

Was Sie erwarten, genau zu kommen? Ein JSON-Objekt? –

Antwort

0

Dies ist Fixed.Find unten zu beantworten, ich bin mit 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); 
      } 

     }); 
Verwandte Themen