Java 在ios应用程序中收到authcode时,尝试从后端服务器交换authcode时重定向\u uri

Java 在ios应用程序中收到authcode时,尝试从后端服务器交换authcode时重定向\u uri,java,ios,oauth-2.0,google-oauth,google-oauth-java-client,Java,Ios,Oauth 2.0,Google Oauth,Google Oauth Java Client,我有一个ios应用程序和一个web应用程序,它从用户处获得授权,生成一个authcode并将其发送到后端java servlet,后者尝试将authcode交换为访问和刷新令牌。从web应用程序交换authcode正在工作,但对于从ios应用程序生成的authcodes,我在交换过程中遇到以下错误 com.google.api.client.auth.oauth2.TokenResponseException:400错误请求 { “错误”:“无效的请求”, “错误\u说明”:“缺少参数:重定向\

我有一个ios应用程序和一个web应用程序,它从用户处获得授权,生成一个authcode并将其发送到后端java servlet,后者尝试将authcode交换为访问和刷新令牌。从web应用程序交换authcode正在工作,但对于从ios应用程序生成的authcodes,我在交换过程中遇到以下错误

com.google.api.client.auth.oauth2.TokenResponseException:400错误请求 { “错误”:“无效的请求”, “错误\u说明”:“缺少参数:重定向\u uri” }

这是进行交换的代码

      public OAuthCodeExchangeResponse exchangeAuthCode(String authCode, boolean isIosApp) throws JSONException, IOException {
OAuthCodeExchangeResponse response = new OAuthCodeExchangeResponse();
GoogleClientSecrets clientSecrets = getClientSecrets(isIosApp);
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow =
    new GoogleAuthorizationCodeFlow.Builder(
        HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
        .setAccessType("offline")
        .build();
GoogleTokenResponse tokenResponse = null;
if(isIosApp == false) {
  tokenResponse = flow.newTokenRequest(authCode)
      .setRedirectUri("postmessage")
      .execute();
} else {
  tokenResponse = flow.newTokenRequest(authCode).execute();
}
GoogleIdToken idToken = tokenResponse.parseIdToken();
GoogleIdToken.Payload payload = idToken.getPayload();
response.setAccessToken(tokenResponse.getAccessToken());
response.setEmail(payload.getEmail());
response.setIdToken(tokenResponse.getIdToken());
response.setRefreshToken(tokenResponse.getRefreshToken());
return response;
}

public GoogleClientSecrets getClientSecrets(boolean isIosApp) throws JSONException, IOException {
GoogleClientSecrets.Details d = new GoogleClientSecrets.Details();
if(isIosApp == false) {
  d.setClientId(WebClientId);
  d.setClientSecret(WebClientSecret);
} else {
  d.setClientId(PhoneClientId);
}
GoogleClientSecrets clientSecrets = new GoogleClientSecrets();
clientSecrets.setInstalled(d);
return clientSecrets;
}

交换ios应用程序生成的authcode时,我必须设置什么重定向uri?在google开发者控制台中为ios应用程序创建的凭据没有重定向uri集。顺便说一句。

urn:ietf:wg:oauth:2.0:oob

您需要已安装应用程序的流程,请参阅