I am using rally Rest API and developing a Rally app.I want to authenticate the user on the basis of Rally Credentials.I have managed to import the rally-rest-api-2.2.1.jar and HTTP jars.I am refering https://github.com/RallyTools/RallyRestToolkitForJava/wiki/User-Guide#setup
I have created a login page and tried to use the constructor.If the user name and password is correct it should navigate to the next page and I can further work on GET requests etc.
My code:
package com.example.apetkar.pocrally;
import android.content.Intent;
import android.net.Credentials;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.rallydev.rest.client.BasicAuthClient;
import com.rallydev.rest.client.HttpClient;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
public class MainActivity extends AppCompatActivity {
EditText etemail;
EditText etpass;
Button btnlogin;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etemail=(EditText) findViewById(R.id.edittextemail);
etpass=(EditText) findViewById(R.id.edittextpassword);
btnlogin=(Button)findViewById(R.id.buttonlogin);
btnlogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
try {
getClient();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
});
}
public HttpClient getClient() throws MalformedURLException {
try
{
BasicAuthClient basicAuthClient = new BasicAuthClient(new URI("https://rally1.rallydev.com"),etemail.getText().toString(),etpass.getText().toString());
basicAuthClient.getServer();
basicAuthClient.setApplicationName("Rally-Mobile");
return basicAuthClient;
}
catch (URISyntaxException e)
{
e.printStackTrace();
}
return null;
}
}
Can anyone suggest what should be the flow or how can I achieve this.Thanks
I'd try to make a simple request in your try block to make sure the credentials are good. Also, you should probably be instantiating a RallyRestApi rather than a BasicAuthClient directly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.