在Smartsheet Auth之后错误重定向到specfic页面

时间:2015-12-08 14:08:50

标签: smartsheet-api smartsheet-java-sdk-v2

   @RequestMapping(value = "/smartsheet.htm", method= RequestMethod.GET)
   public void smartSheetAuth(HttpServletRequest req,HttpServletResponse resp,HttpSession session){
       String userEmail = ************;

       StringBuilder authUrl = new StringBuilder();
       authUrl.append("https://app.smartsheet.com/b/orgsso/");
       authUrl.append(gPlusUser.getDomain());
       /*
       authUrl.append("?loginEmail=");
       authUrl.append(userEmail);*/


       oauth = new OAuthFlowBuilder()
               .setAuthorizationURL(authUrl.toString())
               .setClientId(EnvironmentVariables.SMARTSHEET_CLIENT_ID)
               .setClientSecret(EnvironmentVariables.SMARTSHEET_CLIENT_SECRET)
               .setRedirectURL( APPLICATION_BASE_URL + RequestMapping value to be redirected to)
               .build();
       EnumSet<AccessScope> smartsheetAccessScopes = EnumSet.of(AccessScope.READ_SHEETS,AccessScope.SHARE_SHEETS);
       String url = oauth.newAuthorizationURL(smartsheetAccessScopes, "MY_STATE");

       System.out.println("url >>>"+url);
       resp.sendRedirect(url);
   }

我要做的是组织登录。但是,在我通过身份验证而不是转到OAuthFlowBuilder中指定的重定向网址后,它会将我带到智能表的主页。如果我没有setAuthorizationURL(),我必须从选项中选择Oraganization登录。它有点工作,但我想要实现的是直接进入SSO登录页面,而不是单击组织登录选项,然后再进一步。

我使用smartsheet的开发者工具选项创建了一个应用程序,并且还提到了相同的重定向URL。似乎没什么用。

Now redirect url is optional,但如果没有指定我的IllegalStateException提示。

使用 smartsheet-sdk-java-2.0.0.jar

1 个答案:

答案 0 :(得分:0)

The flow that you're trying to achieve is not possible. i.e., var text = $(this).text().replace(/\s*^([0]|\s)$/g, ''); is not a valid authorization URL for Smartsheet oAuth.

Instead (as described in the Smartsheet oAuth documentation), you must use this URL: https://app.smartsheet.com/b/orgsso/. From there, the user can select the appropriate option to specify how they'd like to login.