0
   @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);
   }

What I am trying to do is Organizational Login . But, after I am authenticated instead of going to the redirect url specified in OAuthFlowBuilder ,it takes me to my home page of smartsheet. If I dont setAuthorizationURL() , I have to select the Oraganization Login from the options. It kinda works, but what I am trying to achieve is to get directly to SSO login page instead of clicking organization login option and then going further.

I have made an app using developer tools option of smartsheet and mentioned the same redirect url there also. Nothing seems to work.

Now redirect url is optional , but if dont specify that I am prompted with IllegalStateException.

Using smartsheet-sdk-java-2.0.0.jar

akgaur
  • 755
  • 1
  • 6
  • 21

1 Answers1

0

The flow that you're trying to achieve is not possible. i.e., https://app.smartsheet.com/b/orgsso/ 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/authorize. From there, the user can select the appropriate option to specify how they'd like to login.

Kim Brandl
  • 13,125
  • 2
  • 16
  • 21
  • It works with the [DEFAULT_AUTHORIZATION_URL ](https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/master/src/main/java/com/smartsheet/api/oauth/OAuthFlowBuilder.java). But the OAuthFlowBuilder gives a setter method "setAuthorizationURL()" to set it to some other url. So with default it works, but the user has to click on Organization login option to go to SSO login page. I want an option where you can somehow directly route the user to SSO page , given that the email is provided by the application. – akgaur Dec 09 '15 at 07:55
  • Also after reading the documentation I couldn't find a way to list the collaborators of a sheet. Is there a method which I missed out. – akgaur Dec 09 '15 at 07:58
  • Yes, I understand what you're trying to acheive -- but it is not possible. Currently there's only one valid value for the Authorization URL (https://app.smartsheet.com/b/authorize) -- i.e., using the SDK, you must use the DEFAULT_AUTHORIZATION_URL -- you cannot set it to any other value. (Not sure why OAuthFlowBuilder provides a setter method "setAuthorizationURL()" -- this might have been inadvertantly included in the SDK.) – Kim Brandl Dec 09 '15 at 14:27
  • Re your other question about collaborators -- please post this as a separate question here on Stackoverflow. (If it's buried in the comments of this unrelated post, others will not be able to discover and benefit from the information.) – Kim Brandl Dec 09 '15 at 14:33
  • Regarding why the sdk allows the authorization url to be set: this is so that the SDK can be used against local dev and staging environments, no just production. – kyanskeem Dec 09 '15 at 18:17