How to get OAuth2.0 access Token (Sina Weibo)

Source: Internet
Author: User
Tags oauth

OAuth2.0 is the next version of the OAuth protocol that was designed since 2006, OAUTH2.0 provides support for Web, desktop, and mobile applications and is simpler and more secure than 1.0 for the entire authorization verification process. Sina Weibo is also the future of the open platform of the most important user authentication and authorization methods.

Developers need to choose the appropriate OAuth authorization process based on different scenarios:
Microblogging login or outbound Web applications, refer to: Authentication Authorization for Web applications (Authorization Code)
Desktop and wireless client applications, refer to: Client Authentication authorization (Resource Owner Password Credentials)
JavaScript class applications, refer to: JavaScript Client Authentication Authorization (implicit Grant)
Micro-Blog station in the application

An instance of the Downloaded Java SDK package is auth4code with the authentication authorization (Authorization Code) of the Web application, and the basic process is as follows:

Before you get access token, you first need to get the app key and the app Secret, and then modify some of the code in Auth4code:
Postmethod.addparameter ("client_id", ""); Appkey Note: Must fill
Postmethod.addparameter ("Redirect_uri", ""); Oauth2 Callback Address Note: This can be left blank
Postmethod.addparameter ("UserId", ""); Weibo account number indicated: Must fill
Postmethod.addparameter ("passwd", ""); Account password indicated: must fill
Note: The above Weibo account and password, I used the test number, through the "My Application"-"edit information", fill out the test number, up to 15, can not be deleted after adding (cannot find the deletion function).

Tokenmethod.addparameter ("client_id", ""); Appkey Note: Must fill
Tokenmethod.addparameter ("Client_secret", ""); Appsecret Note: Must fill
Tokenmethod.addparameter ("Redirect_uri", ""); Callback Address Note: This can be left blank

To execute the program, print the following information in the background:
0 WARN [2011-10-28 09:27:52] Simplehttpconnectionmanager being used. Be sure so httpmethod.releaseconnection () is always called and a only one thread and/or the method is a using this connecti On manager in a time.
main->{"Access_token": "8cd5211ca2312ae42910f642fc5d2d63″, expires_in": 86400}

You can then use the above Access_token to invoke the APIs in the SDK.

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.