答案 0 :(得分:1)
iOS :您可以使用OIDAuthorizationRequest initWithConfiguration:clientId:scope:redirectURL:responseType:state:codeVerifier:codeChallenge:codeChallengeMethod:additionalParameters:
构造函数覆盖PKCE参数。这可用于发送自定义PKCE方法(该库仅支持S256
)。
// builds authentication request
NSString *codeVerifier = [OIDAuthorizationRequest generateCodeVerifier];
OIDAuthorizationRequest *request =
[[OIDAuthorizationRequest alloc] initWithConfiguration:configuration
clientId:kClientID
scope:@"openid profile"
redirectURL:redirectURI
responseType:OIDResponseTypeCode
state:[OIDAuthorizationRequest generateState]
codeVerifier:codeVerifier
codeChallenge:codeVerifier
codeChallengeMethod:@"plain"
additionalParameters:nil];
Android :您可以通过向构建器添加setCodeVerifier(String, String, String)
来覆盖PKCE参数。这可以用于发送自定义PKCE方法(默认情况下,库在具有SHA-256平台支持的客户端上使用S256
。)
import net.openid.appauth.CodeVerifierUtil;
String codeVerifier = CodeVerifierUtil.generateRandomCodeVerifier();
AuthorizationRequest authRequest = new AuthorizationRequest.Builder(
serviceConfig,
CLIENT_ID,
AuthorizationRequest.RESPONSE_TYPE_CODE,
REDIRECT_URI)
.setScope(SCOPE)
.setCodeVerifier(codeVerifier, codeVerifier, "plain")
.build();