【发布时间】:2016-10-20 05:57:17
【问题描述】:
我正在将 uber api 与我的 android 应用程序集成。在 auth 2.0 的情况下,在从 uber 成功授权后,我应该给返回 url 以重定向以进入我的应用程序。这是我的超级登录活动
WebView webView = (WebView) findViewById(R.id.webview);
webView.setWebViewClient(new WebViewClient());
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webView.setScrollbarFadingEnabled(false);
progressBar = ProgressDialog.show(UberLoginActivity.this, "Please wait", "Loading...");
webView.loadUrl("https://login.uber.com/oauth/v2/authorize?client_id=MDyPSkkFFSZHKcntIg9j2mhM7XP665R1&response_type=code");
SessionConfiguration config = new SessionConfiguration.Builder()
.setClientId("***********") //This is necessary
.setRedirectUri("what should be added ") //This is necessary if you'll be using implicit grant
.setServerToken("*********************")
.setEnvironment(SessionConfiguration.Environment.SANDBOX) //Useful for testing your app in the sandbox environment
.setScopes(Arrays.asList(Scope.PROFILE, Scope.RIDE_WIDGETS)) //Your scopes for authentication here
.build();
webView.setWebViewClient(new WebViewClient()
{
public void onPageFinished(WebView view, String url)
{
if (progressBar.isShowing())
{
progressBar.dismiss();
}
}
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl)
{
view.loadUrl("about:blank");
Toast.makeText(getApplication(), " Please check network connectivity", Toast.LENGTH_LONG).show();
super.onReceivedError(view, errorCode, description, failingUrl);
}
});
【问题讨论】:
标签: android web-services url-redirection uber-api