DAuth(도담도담 OAuth)를 편리하게 이용할 수 있도록 돕는 JAVA SDK입니다.
DAuth 공식문서 : https://dauth.b1nd.com
// build.gradle
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.Team-B1ND:DAuth-SDK:{version}'
}
@Bean
public DAuth dauth() {
return DAuthBuilder.create()
.clientId(CLIENT_ID)
.clientSecret(CLIENT_SECRET)
.redirectUrl(REDIRECT_URL)
.build();
}
@Component
public class Sample {
private DAuth dauth;
public Sample(final DAuth dauth) {
this.dauth = dauth;
}
}
final DAuthCodeInfo codeInfo = dAuth.issueCode(id, password);
public final class DAuthCodeInfo {
private Location location;
//getters
}
class Location {
String value;
}
final DAuthTokenInfo tokenInfo = dAuth.issueToken(code);
public final class DAuthTokenInfo {
private String accessToken;
private String refreshToken;
private String tokenType;
private String expiresIn;
//getters
}
final DAuthAccessTokenInfo accessTokenInfo = dAuth.reissueAccessToken(refreshToken);
public final class DAuthAccessTokenInfo {
private String accessToken;
private String tokenType;
private String expiresIn;
//getters
}
final DAuthUserInfo userInfo = dAuth.getUser(accessToken);
public final class DAuthUserInfo {
private DAuthUser user;
public DAuthUser getUser() {
return user;
}
//getters
}
public final class DAuthUser {
private String uniqueId;
private Integer grade;
private Integer room;
private Integer number;
private String name;
private String profileImage; //nullable
private String role;
private String email;
//getters
}
public class DAuthException extends RuntimeException {
private final int status;
public DAuthException(final int status) {
this.status = status;
}
//getter
}