简体   繁体   中英

Web Api Rest service Aunthentation for IOS


I have implemented basic aunthentation from url http://www.asp.net/web-api/overview/security/basic-authentication . Now I have a question that how i send the basic aunthentation to user on login or on register action that is inside controller.

in short how i create a token and integrated in responsed header. Kindly help me i have spent more then 4 hours on it. Thanks

The token is created manually from the credentials users provide.

This means that you have to show a login form in your ios application, gather the username and password and then append the authentication header to each request.

The name of the header is Authorization .

The value is computed as follows. You take the username + ':' + password and encode such string to a byte array. Then you get base64 out of the array.

The value of the header is basic [base64ofusernamepassword] where the [base64ofusernameandpassword] is replaced by the base64 of the username and password you just computed previously.

The exact way of appending custom headers to requests can vary depending on the client technology but it should be easy, no matter which technology is used.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM