我将uber api与我的Android应用程序集成。在auth 2.0的情况下,在uber成功授权进入我的应用程序后,我应该给返回URL重定向。这是我的超级LoginActivity
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);
}
});
答案 0 :(得分:0)
最好在Android上使用SSO进行处理。查看android小部件教程中的相关代码:https://developer.uber.com/docs/ride-requests/tutorials/widget/android#login
这将使用uber应用程序对用户进行身份验证,否则将重定向到应用商店。如果您仍然喜欢使用网页浏览,请跟进。