IOS OAuth Authorization Analysis

Source: Internet
Author: User
Tags oauth

Tag: URL name not registered address TPS MIS COM application

One, the black horse Weibo---> users ' Weibo data
1. Become a Sina developer (join the development camp of Sina Weibo)
* Sign up for a Weibo account, login http://open.weibo.com
account: [email protected]
Password: ios4762450
* Fill in the developer's personal information (e.g. name, date of birth, upload ID)

2. Create an app
* Suppose the application name is called "Black Horse Weibo"
* When the app is created, it enters the "development" phase by default and is eligible for authorization
* Application Related Data
App key:3141202626//Unique identifier of the app
APP secret:ee9de4d2431be061b22fe328332a5228
Redirect uri:http://www.itheima.com

3. User Authorization for "Black Horse Weibo"----OAuth Authorization 2.0
1> Obtaining an unauthorized request Token: Display the login page provided by the server provider
* Url:https://api.weibo.com/oauth2/authorize
* Parameters
client_id true string to assign when applying appkey//To know which app to authorize
Redirect_uri true string to authorize callback address//to which page to jump after authorization succeeds

2> obtaining the authorized request Token
* After the authorization succeeds, automatically jumps to the callback page, for example
http://www.itheima.com/?code=eabdc03cc4cc51484111b1cfd9c4cd0b
Sina will append a parameter after the callback page: request Token after authorization is successful

3> in exchange for an access token based on the authorized request token
* Url:https://api.weibo.com/oauth2/access_token
* Parameters
client_id true string to be assigned when applying the Appkey.
Client_secret true string to be assigned when applying the Appsecret.
Grant_type true string request type, fill in Authorization_code
Code true string calls the code value obtained by authorize.
Redirect_uri true string callback address, which needs to be consistent with the callback address in the registration application
* Return Results
{
"Access_token" = "2.00vwf4geuska7d739148f7608sxa9b";
"Expires_in" = 157679999;
"Remind_in" = 157679999;
UID = 3758830533;
}
UID = = USER_ID = = ID of the current logged on user = = User's unique identity

{
"Access_token" = "2.00vwf4geuska7d739148f7608sxa9b";
"Expires_in" = 157679999;
"Remind_in" = 157679999;
UID = 3758830533;
}

* Access_token and UID of the Go Bai
Access_token:1 users to 1 applications after the successful authorization, the corresponding 1 Access_token, the role is: Allow 1 applications to access 1 users of data
Uid:1 user for 1 uid, every 1 users have their own unique UID
Example:
Tom
John doe

Application 1
Application 2

Zhang San to Application 1, Application 2 authorization succeeded: 1 UID, 2 Access_token
John Doe to Application 2 authorization succeeded: 1 UID, 1 access_token
Above operation: produced 2 uid,3 of Access_token

second, the authorization process common error:
1.invalid_request
1> no required request parameters are passed
2> request parameter is not correct
3> a space in the middle of the URL

2.invalid_client
1> client_id Value Pass error (Appkey is not correct)

3.redirect_uri_mismatch
1> callback address is not correct

Third, the authorized account note
1. If the app has not been audited by Sina, can only access their own or other 15 test account of the micro-blog data

IOS OAuth Authorization Analysis

Related Article

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.