user641427
user641427

Reputation: 1

android app authorisation

I am making an application in android. How to do role authorisation in android. is there any package. please let me know.

Thanks, NVN

Upvotes: 0

Views: 2573

Answers (2)

Amir Raminfar
Amir Raminfar

Reputation: 34150

I never used the Authenticator class. But if you plan to role your own authentication system, its pretty simple. Here are some tips:

  • Authenticate over https
  • Create a webservice that accepts username and password.
  • Once succeeded, save a token or something in preferences so the app knows it is authenticated.
  • I recommend using an oAuth implementation because it is the most safe. (Don't store email addresses, instead use tokens)

Let me know if you need any other help.

Edit:

There isn't a library out there does this for you. You have to create a class called Token or User:

class Token{
 String token;
 Role role;
 User user;
}

Role can be an enum like enum Role{admin, publisher, writer, reader,...}.

Then let's say you authenticate against https://foobar.com/REST/authenticate/?user=foo&password=...

Which returns a simple JSON or XML (I suggest JSON)

{
 token: "12345667",
 role : "publisher",
 user : { userId : "amir", ...}
}

So now you make an HTTPS call and authenticate against a user and password. Then parse the json and create a Token object. Store this token object in the app and you should have everything you need.

Upvotes: 1

SimpsOff
SimpsOff

Reputation: 272

Have you looked at the default Authenticator class? Here's the API from Google I hope that helps. =]

Upvotes: 0

Related Questions