code: public void getUserCredentials( String codeOrUrl )
              throws IOException
      {
          if ( state == null ) {
              // should not occur if this class is used properly
              throw new IllegalStateException( "No anti CSRF state defined" );
          }
  
          String code;
          if ( codeOrUrl.startsWith( "http://" ) || codeOrUrl.startsWith( "https://" ) ) {
              // It's a URL : extract code and check state
              String url = codeOrUrl;
  
              LOGGER.debug( "redirect URL: {}", url );
  
              URI uri = URI.create( url );
              String error = URIUtil.getQueryParameter( uri, "error" );
              String errorDescription = URIUtil.getQueryParameter( uri, "error_description" );
              if ( error != null ) {
                  String msg = "User authorization failed : " + error;
                  if ( errorDescription != null ) {
                      msg += " (" + errorDescription + ")";
                  }
                  throw new CStorageException( msg );
              }
  
              String stateToTest = URIUtil.getQueryParameter( uri, "state" );
              if ( !state.equals( stateToTest ) ) {
                  throw new CStorageException( "State received (" + stateToTest + ") is not state expected (" + state + ")" );
              }
              code = URIUtil.getQueryParameter( uri, "code" );
              if ( code == null ) {
                  throw new CStorageException( "Can't find code in redirected URL: " + url );
              }
  
          } else {
              // It's a code
              code = codeOrUrl;
          }
  
          UserCredentials userCredentials = sessionManager.fetchUserCredentials( code );
          // From access token we can get user id...
          String userId = storageProvider.getUserId();
          LOGGER.debug( "User identifier retrieved: {}", userId );
  
          // ...so that by now we can persist tokens :
          userCredentials.setUserId( userId );
          sessionManager.getUserCredentialsRepository().save( userCredentials );
      }
docs: Gets users Credentials
  
  @param codeOrUrl code or redirect URL provided by the browser
  @throws IOException