美文网首页
第三方登录jar(qq、wechat、weibo)

第三方登录jar(qq、wechat、weibo)

作者: 稽无贼 | 来源:发表于2018-05-23 09:11 被阅读37次

1.本文介绍

        研究了几天第三方登录,逻辑已经在上一篇列了出来了,但是怎么实现呢?这就推荐一个jar包(仅对java,其他语言仅供参考)。

2.废话不多说,上货

        github地址:https://github.com/belerweb/social-sdk

        或者在maven的pom中增加依赖:

            <dependency>

                    <groupId>com.belerweb</groupId>

                    <artifactId>social-sdk</artifactId>

                    <version>0.0.5</version>

            </dependency>

3.3个第三方获取access_token的例子

只举一个qq:

import org.junit.Assert;

import com.belerweb.social.bean.Result;

import com.belerweb.social.qq.connect.api.OAuth2;

import com.belerweb.social.qq.connect.api.QQConnect;

import com.belerweb.social.qq.connect.bean.AccessToken;

public class TestQQ {

public static void main(String[] args) {

    String clientId="*******";

    String clientSecret="***********************";

    String redirectUri="********************************";

     String code="********************************";

    QQConnect connect=new QQConnect(clientId,clientSecret,redirectUri);

    OAuth2 oauth=connect.getOAuth2();

    Resultresult=oauth.accessToken(code);

    System.out.println(result.getResult().getToken());

}

}

相关文章

网友评论

      本文标题:第三方登录jar(qq、wechat、weibo)

      本文链接:https://www.haomeiwen.com/subject/wxbljftx.html