当前位置: 首页 > 知识库问答 >
问题:

在android应用程序上使用API REST接口进行用户身份验证

诸腾
2023-03-14
private void loginpage() {
    final Button button = findViewById(R.id.button4);
    button.setOnClickListener(v -> {
        String username = findViewById(R.id.editTextTextPassword).toString();
        String password = findViewById(R.id.editTextTextPersonName).toString();

        try {
            webUntisAPI.login(username,password,"Spengergasse"); //Accesses the API to login
            setContentView(R.layout.activity_main);
            mainpage();
        }catch (RuntimeException ignored){
             //On fail don't switch view
        }

    });
}
W/System.err:     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1600)
        at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:115)
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
        at java.net.InetAddress.getAllByName(InetAddress.java:1152)
        at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
        at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
        at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
        at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
        at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
        at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
W/System.err:     at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
        at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
W/System.err:     at com.example.myapplication.WebUntisAPI.login(WebUntisAPI.java:49)
        at com.example.myapplication.MainActivity.lambda$loginpage$0$MainActivity(MainActivity.java:56)
        at com.example.myapplication.-$$Lambda$MainActivity$f4xelUsFrwZaMU-fM7MXdfynjRQ.onClick(Unknown Source:2)
        at android.view.View.performClick(View.java:7448)
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
        at android.view.View.performClickInternal(View.java:7425)
W/System.err:     at android.view.View.access$3600(View.java:810)
        at android.view.View$PerformClick.run(View.java:28296)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/Choreographer: Skipped 33 frames!  The application may be doing too much work on its main thread.
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);

暂时还没有答案

 类似资料:
  • 这是服务到服务身份验证中概述的规则的一个例外吗?该规则规定需要设置为接收服务的url(例如https://xxxxx.run.app)。和是一回事吗? 最后,除了使用googlecloudsdk(即imaging不存在)之外,是否还有其他方法使用用户帐户而不是服务帐户进行身份验证?

  • 嗨,好几天了,我都被困在这上面了!在使用本指南转换我的react应用程序后,我尝试使用KeyClope对我的electron应用程序进行身份验证。 当我运行'npm运行电子:dev'时,keyCloak会重定向到登录页面。然而,当我运行'npm运行电子:prod'这失败。 来自KeyClope服务器的日志显示: 请注意,重定向_uri是'file:///...“我相信这就是原因。 我也试图改变下面

  • 问题内容: 我想在我的Java应用程序中使用Windows NTLM认证来透明地认证Intranet用户。如果使用浏览器(单点登录),用户将不会注意到任何身份验证。 我发现了一些具有NTLM支持的库,但是不知道要使用哪个库: http://spnego.sourceforge.net/ http://sourceforge.net/projects/ntlmv2auth/ http://jcifs

  • 我有一个Azure Function应用程序,运行在使用Azure AD B2C进行身份验证的高级计划中。简单SPA的用户通过广告B2C的登录流获得他们的代币。SPA在AD B2C中注册为应用程序,功能应用程序的身份验证配置为使用该应用程序注册: 身份验证/Azure Active Directory/高级 ClientId:<代码> 颁发者Url:<代码>https:// 使用通过SPA获得的这

  • 我正在尝试使与和一起工作。我试着按照spring-boot-sample-secure和spring-boot-sample-web-secure中的指南去做,但是我没有让它起作用。 我正在尝试构建一个没有任何ui交互的REST应用程序。因此,我发现这两个样品都不完全适合我的目的。目前我的解决方案是使用AOP。 解决方案对我有效。然而,我想知道这是否是一个好的解决方案。我很好奇是否有更好的解决办法

  • 我想使用 Firebase 构建一个 Android 应用。Firebase 提供了登录屏幕 https://github.com/firebase/firebase-login-demo-android 的演示代码。 但是,我希望用户能够使用用户已经在Android的集中式帐户管理器中输入的帐户信息,而不是让用户输入他们的帐户信息。 我已经在 https://developer.android.