iOS development Project Chapter -17oauth authorization process

Source: Internet
Author: User

iOS development Project Chapter -17oauth authorization process

First, Web presentation

1. Open the Open platform address

2. Create an App

3. Fill in the Personal developer information

4. Create a new app

5. View the API interface provided by Weibo

6. The OAuth2 is used here.

7. Complete description of the interface

Description: The URL provided is the login interface

8. Post-creation application information

9. Cannot directly access the URL provided, but also need to pass in the necessary parameters

To pass in the necessary 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

Description

Click Apply Info-Advanced info, set authorization callback page

After passing two parameters

After clicking on the top of the text, jump to the page where the callback address is located

10. Affiliate Account

After you associate your account, you can log in using that account

Note : An app that has not been approved can only have 15 accounts associated with it, and in addition to the 15 accounts that can be associated with the app, the developer can authorize the app with his or her own account, and the app's account is also a Weibo account.

11. Login with account, authorize

Once the authorization is successful, it will automatically jump to the callback page

tip : Note clear the page cache.

Ii. description of the authorization process

(a) Weibo---> users ' microblog data at the top of the text

1. Become a Sina developer (join the development camp of Sina Weibo)

* Sign up for a Weibo account, login http://open.weibo.com

Account Number: XXXXXXX

Password: XXXXX

* Fill in the developer's personal information (such as 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

Unique identifier of app key:3141202626//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 is assigned 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) Obtain the authorized request Token

* After the authorization succeeds, automatically jumps to the callback page, for example

http://http://www.cnblogs.com/wendingding/?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

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

For 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

(ii) Common errors in the authorization process:

1.invalid_request

(1) No required request parameters are passed

(2) The request parameter is not correct

(3) There are spaces in the middle of the URL

2.invalid_client

(1) client_id Value Pass error (Appkey not correct)

3.redirect_uri_mismatch

(2) Callback address mismatch

(iii) 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

Three, the authorization process diagram

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.