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
- -(Void) authThroughGoogle
- {
- NSString * clientId = GOOGLE_CLIENT_ID;
- NSString * clientSecret = GOOGLE_CLIENT_SECRET;
- NSString * scope = GOOGLE_AUTH_SCOPE;
- Using * authViewController = [[using alloc] initWithScope: scope clientID: clientId clientSecret: Using keychainItemName: Using delegate: self finishedSelector: @ selector (viewController: Using: error :)] autorelease];
- NSString * html = @ "
- AuthViewController. initialHTMLString = html;
- [Self. navigationController pushViewController: authViewController animated: YES];
- }
After obtaining the authentication result, obtain the Auth Token from the server:
Object-c code
- -(Void) viewController :( GTMOAuth2ViewControllerTouch *) viewController finishedWithAuth :( GTMOAuth2Authentication *) auth error :( NSError *) error {
- If (error! = Nil ){
- NSLog (@ "Auth failed! ");
- [Self showAlertView: [error localizedDescription];
- } Else {
- NSLog (@ "Auth successed! : % @ ", [Auth accessToken]);
- NSString * token = [AuthHelper getAuthTokenThroughGoogle: [auth accessToken];
- If (token! = Nil ){
- [[NSUserDefaults standardUserDefaults] setObject: token forKey: APP_NAME];
- [Self goToMainPage];
- } Else {
- [Self showAlertView: @ "Get get the authorize token"];
- }
- }
- }
] 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.