2013-02-24 566 views
2

我試圖授權vk.com用戶(OAuth 2.0),如herehere所述。問題是:每次我看到一個空白屏幕時,除了單次調用GC之外似乎沒有任何事情發生。我測試了我的WebView,它顯示了任何以https開頭的地址,沒有任何問題。我想我的網址是無效的,但我也沒有看到任何錯誤消息,它看起來像WebView只是不顯示授權對話框。我對OAuth系統不熟悉,非常感謝任何幫助。代碼如下android-試圖授權用戶訪問vk.com

P.S.我使用位掩碼8,因爲我只需要訪問用戶的音頻。

private static final String ACCESS = "https://oauth.vk.com/authorize?client_id=123456&redirect_uri= https://oauth.vk.com/blank.html/&display=touch&response_type=token&scope=8"; 

     private WebViewClient mWebClient = new WebViewClient() { 

    @Override 
    public boolean shouldOverrideUrlLoading(WebView view, String url) { 
    return false; 
} 
@Override 
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { 
    handler.proceed(); 
} 

    }; 
    web = (WebView)findViewById(R.id.webView1); 
    web.setWebViewClient(mWebClient); 
     web.getSettings().setJavaScriptEnabled(true); 
     web.loadUrl(ACCESS); 

回答

1

只是想通了。由於可能有開發者有興趣訪問vk.com,所以作爲回答發佈。 Android設備的正確授權請求如下所示:

private final String VK_AUTH = "https://oauth.vk.com/authorize?client_id=123456&redirect_uri=https://oauth.vk.com/blank.html&scope=8&display=touch&response_type=token ";