Weibo login for third-party login

The process is the same as QQ login. If you don’t understand, please refer to the previous article http://service201503251905.iteye.com/admin/blogs/2196038
to download the sdk https://github.com/sunxiaowei2014/weibo4j-oauth2-beta3.1.1/
due to this file There is no jar package, but there are source files. You need to package them yourself. After packaging, put them under your project. There is a configuration file config.properties
in the scr directory and put it under the source directory.
Modify the configuration as follows:
Lient_ID = App Key applied for you
client_SERCRET = for The App Secret
redirect_URI you applied for =
place a link to access the server for the uri 1 login page requested after successful login <a class="weibo-login ml-10" href='/weibo-login.html'></a>

server The code is as follows
        @RequestMapping(method=RequestMethod.GET,value="weibo-login")
public String weiboLogin(){
try {
return "redirect:" + new weibo4j.Oauth().authorize("code");
} catch ( WeiboException e) {
e.printStackTrace();
}
return null;
}

2 Action returned after successful
       login @Privilege(login = false)
@RequestMapping(method=RequestMethod.GET,value="weibo-redirect")
public String weiboRedirect(@RequestParam String code ){
return "redirect:/main.html";
}

3 Get information

weibo4j.Oauth oauth = new weibo4j.Oauth();
weibo4j.http.AccessToken accessToken = oauth.getAccessTokenByCode(code);
String token = accessToken.getAccessToken() ;
weibo4j.Account account = new weibo4j.Account(token);
String uid = account.getUid().getString("uid");
Since it is similar to QQ login, it is not explained

here . Welcome to Zhouwangpu http://www. zhouwangpu.com/login.html View examples

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327095999&siteId=291194637