1. 程式人生 > 其它 >pig專案feign呼叫登入/oauth/token介面;pig4cloud專案feign呼叫登入/oauth/token介面;feign呼叫OAuth2登入介面;feign呼叫oAuth2登入介面

pig專案feign呼叫登入/oauth/token介面;pig4cloud專案feign呼叫登入/oauth/token介面;feign呼叫OAuth2登入介面;feign呼叫oAuth2登入介面

 開始沒加headers = {"Content-Type: multipart/form-data", "Authorization=Basic cGlnOnBpZw=="} 一直請求報401

 feign呼叫401

import com.pig4cloud.pig.common.core.constant.SecurityConstants;
import com.pig4cloud.pig.common.core.constant.ServiceNameConstants;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

@Service
@FeignClient(value 
= ServiceNameConstants.AUTH_SERVICE, fallbackFactory =PiaAuthServiceFallbackFactory.class) public interface PigAuthService { @PostMapping(value = "/oauth/token", headers = {"Content-Type: multipart/form-data", "Authorization=Basic cGlnOnBpZw=="}) Object oauth( @RequestParam Map<String, String> parameters, @RequestHeader(SecurityConstants.FROM) String from
); }