1.本文介紹
????????研究了幾天第三方登錄失球,邏輯已經(jīng)在上一篇列了出來了,但是怎么實現(xiàn)呢帮毁?這就推薦一個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());
}
}