2015-02-24 81 views
0

我在我的應用程序中使用SoundCloud API,我希望爲Google +登錄添加支持.Facebook和電子郵件登錄很有效。Android的SoundCloud API - Google+ - 登錄無效

我按照步驟從[https://developers.soundcloud.com/docs/api/reference][1]並使用WebView顯示連接URL。對於FB登錄,我被髮送到我指定的redirect_uri,但對於Google+,這不會發生,我將返回到空白頁面。

我應該添加任何Google+特殊設置嗎?

[更新] 而從網頁流量的網址是:

https://accounts.google.com/o/oauth2/auth?zt=ChRrSW5rQzhRb0FCN2FXYmN2OUU3UBIfSWgtRWd0QlJVcThSWUZacjk1dXlndlZSZ0syTWx3SQ%E2%88%99APsBz4gAAAAAVO80WV2bOdZGqYKRwpTOIlAweRpfRufL&from_login=1&hl=ro&as=-3b89b18baa28338a

謝謝。

+0

[使用Google+的Soundcloud API移動OAUTH登錄可能重複無法在Android上運行](http://stackoverflow.com/questions/24877284/soundcloud-api-mobile-oauth-login-using-google-isnt- work-on-android) – 2016-07-21 23:23:03

回答

0

這是我在做什麼了SoundCloudlogin

web.getSettings().setJavaScriptEnabled(true); 
    web.loadUrl(url+"&client_id="+CLIENT_ID+"&redirect_uri=http://localhost&response_type=token&scope=non-expiring&display=popup"); 
    web.setWebViewClient(new WebViewClient() { 
      boolean authComplete = false; 
      @Override 
      public void onPageStarted(WebView view, String url, Bitmap favicon){ 
      super.onPageStarted(view, url, favicon); 
      progress_dialog.show_message("Connecting SoundCloud"); 
      progress_dialog.show_dialog(); 
      } 
     String authCode=""; 
      @Override 
      public void onPageFinished(WebView view, String url) { 
       super.onPageFinished(view, url); 
       progress_dialog.Cancel_dialog(); 
       Log.i("URLLLL", url); 
       if (url.contains("access_token=") && authComplete != true) { 
        for(int t=32;t<url.length();t++){ 
         if(!(url.charAt(t) == '&')) 
         authCode = authCode+url.charAt(t); 
         else 
         break; 
        } 
        Log.i("CODE true", "CODE : " + authCode); 
        authComplete = true; 
        SharedPreferences.Editor edit = pref.edit(); 
        edit.putString("SoundCloud_Code", authCode); 
        edit.putInt("SoundCloud_signinflag", 1); 
        edit.commit(); 
        sign_in_flag = 1; 
        auth_dialog.dismiss(); 
        new getprofile().execute(); 
       }else if(url.contains("error=access_denied")){ 
        Log.i("CODE false", "ACCESS_DENIED_HERE"); 
        authComplete = true; 
        auth_dialog.dismiss(); 
       } 
      } 
     }); 
    auth_dialog.show(); 

,它只是工作完美。

請試試這個。

+0

謝謝你的回答。這適用於Facebook(但FB之前也工作過),但對於Google +我仍然收到一個空白屏幕。我點擊Google+按鈕。我介紹用戶和通行證。我點擊登錄,然後我得到了空白屏幕,這是來自webview的URL:(請參閱更新) – lorydi 2015-02-26 14:47:55