/** * Create a Quandl session with detailed SessionOptions. No attempt will be made to read the java property <em>quandl.auth.token</em> even * if available. Note creating this object does not make any actual API requests, the token is used in subsequent requests. * * @param sessionOptions a user created SessionOptions instance, not null * @return an instance of the Quandl session, not null */ public static QuandlSession create(final SessionOptions sessionOptions) { ArgumentChecker.notNull(sessionOptions, "sessionOptions"); return new QuandlSession(sessionOptions); }
/** * Create a Quandl session without an authorization token (authToken). An attempt will be made to read the java property * <em>quandl.auth.token</em> and use that if available. Any resulting SecurityException is logged at debug level, otherwise it is ignored * and no auth token is used. Using a token means you can make more requests. Note creating this object does not make any actual API * requests, the token is used in subsequent requests. * * @return an instance of the Quandl session, not null. */ public static QuandlSession create() { try { String authToken = System.getProperty(GenericQuandlSession.QUANDL_AUTH_TOKEN_PROPERTY_NAME); if (authToken != null) { return new QuandlSession(SessionOptions.Builder.withAuthToken(authToken).build()); } } catch (SecurityException se) { s_logger.debug("Error accessing system property " + GenericQuandlSession.QUANDL_AUTH_TOKEN_PROPERTY_NAME + ", falling back to not using an auth token", se); } return new QuandlSession(SessionOptions.Builder.withoutAuthToken().build()); }
/** * Create a Quandl session to use a specific authorization token (authToken) with all requests. Using a token means you can make more * requests. Note that this method does not check the quandl.auth.token property. Creating this object does not make any actual API * requests, the token is used in subsequent requests. * * @param authToken a Quandl API authorization token * @return an instance of the Quandl session with an embedded authorization token */ public static QuandlSession create(final String authToken) { ArgumentChecker.notNull(authToken, "authToken"); return new QuandlSession(SessionOptions.Builder.withAuthToken(authToken).build()); }