@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
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.