OAuth2.0 certification for Sina Weibo open platform, oauth2.0 for Sina Platform

Source: Internet
Author: User

OAuth2.0 certification for Sina Weibo open platform, oauth2.0 for Sina Platform

1. Create a mobile app on the open platform, obtain the key and secret, and enter the URL of the authorization callback page in "application information". The URL can be any one, but it must be accessible.


2. Use the api provided by Sina: https://api.weibo.com/oauth2/authorizeto go to the authorization token authorization page (webpage form), enter your Sina Weibo account, and submit it.

Parameter: client_id, that is, appkey,

Redirect_uri is the URL of the authorization callback page just filled in

Response_type is code

Display is mobile, indicating that it is displayed on mobile devices.

State: authorize. Optional.

For example:

Https://api.weibo.com/oauth2/authorize? Client_id = 65XXX7423 & redirect_uri = https://api.weibo.com/oauth2/default.html&response_type=code&display=mobile&state=authorize


3. After submitting the account and password, you will receive the redirection data multiple times, but only the URL with the prefix "https://api.weibo.com/oauth2/default.html" contains the required codevalue.

For example, return

Https://api.weibo.com/oauth2/default.html? State = authorize & code = ea335c8922415641de2040abe5479139. The code value is used as an API parameter for obtaining access token. The code here is dynamically changed.


4. Use the api provided by Sina: https://api.weibo.com/oauth2/access_token=token

The code parameter here is just redirected.

For example:

Https://api.weibo.com/oauth2/access_token? Client_id = 650627423 & client_secret = 65acaa05a0ef024071d0ede678e165fc & grant_type = authorization_code & redirect_uri = https://api.weibo.com/oauth2/default.html&code=11488678f95d1793f2dd94494b4b5dbe


5. Save the value of the keyword "access_token" in the data returned in Step 4 to your local device. Then you can use this token to access various APIs and obtain various data.


6. The source code is provided here. It was written nine months ago and can be run. However, I just tested it, because the official api has been changed, so I cannot get the homepage Weibo data. Refer to the official documentation and change the api parameters so that they can run smoothly.

Http://download.csdn.net/detail/awaylin113/7780505



How To Enable Automatic Logon for Sina Weibo OAuth20 Certification

There is an instance under the API download SDK page. As shown in the following figure, you will get what you want very easily. Let's give you a connection. Don't just see the download. Let's take a look at the example code.google.com/p/weibo4j/ below/

How To Enable Automatic Logon for Sina Weibo OAuth20 Certification

According to Twitter's API Wiki, basic OAuth verification workflow is as follows:
1. The program uses api.twitter.com/oauth/request_tokento get a request token from twitter.com.
2. The program then directs the user to the api.twitter.com/oauth/authorizepage.
3. If the user agrees to the authorization, twitter.com will display a 7-digit PIN code.
4. You need to copy the PIN code and return to the program.
5. The program prompts the user to enter the PIN code.
6. Then, the program uses the PIN code as the value of the parameter oauth_verifier, then calls api.twitter.com/oauth/access_tokento verify the real pincode, and replaces request_token with access_token.
7. A access_token will be returned after Twitter, and the program generates the OAuth signature after the token.
 

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.