IOS development-Stage 3-Sina Weibo (1) documentation, stage 3 of ios
0 https://itunes.apple.com/cn/app/you-dao-ci-dian/id491854842? Mt = 12 id1_54842 this is also called the Apple ID, which is different from the apple id used for downloading an AppStore (the account used for downloading)
Register Sina mail
Register Sina Weibo
Open Platform becomes a developer
Register an account
Enter developer information when creating an app mobile app
The basic information is displayed after the basic information is filled in after the new application is created.
Record:
App Key: 3744355969
App Secret: f4cd173c39d67d3f3fef43d5c63fe9c0
Advanced Information
OAuth2.0 authorization settings
Authorization callback page when you authorize your application, the open platform calls back the address you entered
Cancel authorization callback page when a user cancels authorization for your application on the my application management page, the open platform calls back the address
Http://www.zhiyou100.com
2. OAuth2.0 authorization process
If a student (a third-party application) wants to take a leave of absence, he/she needs to write a ticket (loading the authorization page), sign the form (agree to authorize) with the class teacher, and sign the instructor (authentication code ), school Stamp (obtain access token)
Flowchart:
Client refers to a third-party application, Resource Owner refers to the user, Authorization Server is Sina's Authorization Server, and Resource Server is the Resource Server.
The purpose of authorization authentication is to use a series of process apps to access user information on the resource server.
Sina has OAuth Mechanism
The APP wants to access resource 0 on the resource server.
A: The APP sends an authorization request to the user (when the user clicks share, an interface is provided for the user to log on and authorize)
B: The user authorizes the APP (the user logs on and authorizes the APP to obtain the verification code)
C: The APP requests Access Token from the authorization server (the APP uses the verification code to request Access Token)
D: The authorization server returns the Access Token to the APP (the authorization server returns the Access Token)
E: the APP submits the Access Token to the resource server (the APP uses the Access Token to Access the resource server)
The resource server provides protected information to the APP (all your information is verified on the resource server and the access token is provided to the APP)
Code implementation process:
Create webView settings proxy Implementation Protocol Method
First, access the authorization interface oau22.
Https://api.weibo.com/oauth2/authorize? Client_id = 1514930435 & redirect_uri = http://www.zhiyou100.com & display = mobile
Build request
WebView Loading
User Logon
When the Protocol method is about to start loading a request
Returns an authorized connection click authorization.
The authorization server returns a connection that contains (redirect_uri + code)
After authorization is complete, run shouldStartLoadWithRequest to check whether the code is returned.
Build a request based on code
Obtain the access token in the request end Method
OAuth
The OAuth Protocol provides a secure, open, and simple standard for user resource authorization. Unlike the previous authorization method, OAUTH does not allow a third party to access user account information (such as user name and password ), that is, a third party can apply for authorization of the user's resources without using the user name and password. Therefore, OAuth is secure.
For example, the handsome APP needs to access the handsome user's resources Sina