Unified authentication for iOS clients and servers and for ios clients

Source: Internet
Author: User

Unified authentication for iOS clients and servers and for ios clients

Recently, colleagues in the company made an internal class about in their spare time. me (https://about.me/) site Ocelots, want to come to be a very foreign attention, later with the customer to introduce the company, directly log on to the site, when talking about who, the home page, photos, experiences, hobbies, and so on are clearly displayed. I started to think that if it was such a tool, there would be no regrets on the mobile end, because we had to show our team members to our customers at any time and on any occasion.

After the project framework is set up, the first requirement is unified authentication. Ocelots uses Google oau2and Mozilla Persona as the website portal. The authentication method structure is as follows (Google oau2as an example, Mozilla Persona works the same ):
 

Google oau2provides support for iOS systems. Therefore, it is very easy to implement an authentication mechanism identical to Ocelots on the Ocelots_iOS client. However, the difficulty lies in how to unify the authentication mechanism between the two?
After studying the authentication mechanism of Google oau2, I found that the authentication mechanism is as follows:
 

Therefore, we can follow the steps below to unify the Ocelots_iOS client and Ocelots client authentication mechanism,
1. register the Application ID for Ocelots_iOS and ensure that the authorization scope of the Ocelots_iOS and Ocelots applications is consistent.
2. bind an authorize_token to the user of Ocelots to obtain all information about the account in the system.
3. Implement the Ocelots_iOS client authentication mechanism as follows:
 
The Code is as follows:
Use the Google oau2plug-in to call the Google authentication interface:

Object-c code  
  1. -(Void) authThroughGoogle
  2. {
  3. NSString * clientId = GOOGLE_CLIENT_ID;
  4. NSString * clientSecret = GOOGLE_CLIENT_SECRET;
  5. NSString * scope = GOOGLE_AUTH_SCOPE;
  6. Using * authViewController = [[using alloc] initWithScope: scope clientID: clientId clientSecret: Using keychainItemName: Using delegate: self finishedSelector: @ selector (viewController: Using: error :)] autorelease];
  7. NSString * html = @ "
  8. AuthViewController. initialHTMLString = html;
  9. [Self. navigationController pushViewController: authViewController animated: YES];
  10. }



After obtaining the authentication result, obtain the Auth Token from the server:

Object-c code  
  1. -(Void) viewController :( GTMOAuth2ViewControllerTouch *) viewController finishedWithAuth :( GTMOAuth2Authentication *) auth error :( NSError *) error {
  2. If (error! = Nil ){
  3. NSLog (@ "Auth failed! ");
  4. [Self showAlertView: [error localizedDescription];
  5. } Else {
  6. NSLog (@ "Auth successed! : % @ ", [Auth accessToken]);
  7. NSString * token = [AuthHelper getAuthTokenThroughGoogle: [auth accessToken];
  8. If (token! = Nil ){
  9. [[NSUserDefaults standardUserDefaults] setObject: token forKey: APP_NAME];
  10. [Self goToMainPage];
  11. } Else {
  12. [Self showAlertView: @ "Get get the authorize token"];
  13. }
  14. }
  15. }

] The Apsara stack client (imentohust) is stuck on the authentication server for ios.

The ingress network cable of the wireless route should not be connected to the WAN port. The LAN port should be connected, and the DHCP server function of the router should be disabled.
Use a PC to test whether you can log on to ruijie through WIFI.

Why have I been stuck in wifi uniform authentication when I installed the Tianyi broadband client on my computer?

Are you a campus user? If you are not a campus user, you are not recommended to use the Tianyi client. Problems may often occur. If the client reports an error, you may want to send all the messages. If you can, it is not good to use broadband connections.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.