how to call RESTful web service from android?

前端 未结 1 1181
深忆病人
深忆病人 2021-01-27 12:45

I have written REST web service in netbean IDE using jersey framework and java. For every request user need to provide username and password , I know the authentication is not g

相关标签:
1条回答
  • 2021-01-27 13:18

    Do you use basic authentication? if so: use this.

    if (username != null && password != null) {
                client.getCredentialsProvider().setCredentials(
                        new AuthScope(null, -1),
                        new UsernamePasswordCredentials(username, password));
            }
    

    or you can add those in a header as setHeader("Authentication", "Basic "+Base64EncodedString(username,pass);

    What you are doing is using Proxy authentication. why?

    this article may also be helpful somehow:

    link

    also the -u stands for the ntlm authorization so maybe look into that too. there were some topics where it said it is not supported on android or something but i am sure if you need it you can make a workaround.

    0 讨论(0)
提交回复
热议问题