GSM-MSG / GAuth-SDK-Kotlin

GAuth Software Development Kit in Kotlin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GAuth SDK Kotlin

Dependency

Gradle

repositories

// build.gradle
maven { url 'https://jitpack.io' }

// or

// build.gradle.kts
maven { url = uri("https://jitpack.io") }

dependencies

// build.gradle
implementation 'com.github.GSM-MSG:GAuth-SDK-Kotlin:v1.0.1'

// or

// build.gradle.kt
implementation("com.github.GSM-MSG:GAuth-SDK-Kotlin:v1.0.1")

Maven

repositories

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>

dependencies

<dependency>
	  <groupId>com.github.GSM-MSG</groupId>
	  <artifactId>GAuth-SDK-Kotlin</artifactId>
	  <version>v1.0.1</version>
</dependency>

Configuration

Bean

@Bean
public GAuth gauth() {
	return new GAuthImpl();
}

DI

@Component
public class Component{
	private GAuth gAuth;

	public Component(GAuth gAuth){
		this.gAuth = gAuth;
	}
}

Code

해당 메서드를 통해 발급 가능

gAuth.generateCode(email, password);
public class GAuthCode {
    private String code;
}

코드 발급후 해당 객체를 리턴한다.


Token

gAuth.generateToken(email, password, clientId, clientSecret, redirectUri);

gAuth.generateToken(code, clientId, clientSecret, redirectUri);

이메일, 패스워드, 클라이언트 아이디, 클라이언트 시크릿, 리다이렉트 uri를 사용해서 토큰을 발급할 수도 있고,

코드, 클라이언트 아이디, 클라이언트 시크릿, 리다이렉트 uri를 사용해서 발급할 수도 있다.

public class GAuthToken {
    private String accessToken;
    private String refreshToken;
}

토큰 발급 후 해당 객체를 리턴한다.


Refresh Token

refreshToken을 통해서 토큰을 발급할 수 있다.

gAuth.refresh(refreshToken);
public class GAuthToken {
    private String accessToken;
    private String refreshToken;
}

토큰 발급 후 해당 객체를 리턴한다.


User Info

gAuth.getUserInfo(accessToken);

accessToken을 사용해 유저 정보를 가져올 수 있다.

public class GAuthUserInfo {
    private String email;
    private String name;
    private Integer grade;
    private Integer classNum;
    private Integer num;
    private String gender; // MALE | FEMALE
    private String profileUrl;
    private String role; // ROLE_STUDENT | ROLE_TEACHER
}

유저 정보를 해당 객체에 담아서 리턴한다.

grade, classNum, num, number, gender, profileUrl은 nullable로
GAuth SDK Java는 Type!를 반환하지만(문제는 없음) GAuth SDK Kotlin은 Type?를 반환한다.


Exception

응답코드가 200이 아니면 예외코드를 담은 GAuthException을 throw한다.

About

GAuth Software Development Kit in Kotlin

License:MIT License


Languages

Language:Kotlin 100.0%