package com.sptg.permissions.api.thirdauth.util;

import com.sptg.permissions.api.thirdauth.request.AuthCtwingRequest;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.request.*;

public class AuthRequestUtil {

    /**
     * 根据具体的授权来源，获取授权请求工具类
     *
     * @param source
     * @return
     */
    public static AuthRequest getAuthRequest(String source) {
        AuthRequest authRequest = null;
        switch (source.toUpperCase()) {
            case "CTWING":
                authRequest = new AuthCtwingRequest(AuthConfig.builder()
                        .clientId("8135892866")
                        .clientSecret("SnpYtQuSDrb3igRzIzFerfLxOMTC8sd2")
                        .redirectUri("http://73zbyp7slu.51xd.pub/permissions/third/authentication/callback/ctwing")
                        .build());
                break;
            default:
                break;
        }
        if (null == authRequest) {
            throw new AuthException("未获取到有效的Auth配置");
        }
        return authRequest;
    }
}
