@@ -37,6 +37,8 @@ class App {
3737 /**
3838 * Gets a token from the API using client credentials
3939 * @return {Promise(token, error) } A Promise that is fulfilled with the token string or rejected with an error
40+ *
41+ * @deprecated Please switch to using the API key.
4042 */
4143 getToken ( ) {
4244 return this . _config . token ( ) ;
@@ -46,6 +48,8 @@ class App {
4648 * Sets the token to use for the API
4749 * @param {String } _token The token you are setting
4850 * @return {Boolean } true if token has valid fields, false if not
51+ *
52+ * @deprecated Please switch to using the API key.
4953 */
5054 setToken ( _token ) {
5155 let token = _token ;
@@ -73,8 +77,12 @@ class App {
7377 }
7478
7579 _validate ( { clientId, clientSecret, token, apiKey, sessionToken} ) {
80+ if ( clientId || clientSecret ) {
81+ console . warn ( 'Client ID/secret has been deprecated. Please switch to using the API key. See here how to do ' +
82+ 'the switch: https://blog.clarifai.com/introducing-api-keys-a-safer-way-to-authenticate-your-applications' ) ;
83+ }
7684 if ( ( ! clientId || ! clientSecret ) && ! token && ! apiKey && ! sessionToken ) {
77- throw ERRORS . paramsRequired ( [ 'Client ID' , 'Client Secret '] ) ;
85+ throw ERRORS . paramsRequired ( [ 'apiKey ' ] ) ;
7886 }
7987 }
8088
@@ -110,6 +118,9 @@ class App {
110118 this . solutions = new Solutions ( this . _config ) ;
111119 }
112120
121+ /**
122+ * @deprecated Please switch to using the API key.
123+ */
113124 _getToken ( resolve , reject ) {
114125 this . _requestToken ( ) . then (
115126 ( response ) => {
@@ -124,6 +135,9 @@ class App {
124135 ) ;
125136 }
126137
138+ /**
139+ * @deprecated Please switch to using the API key.
140+ */
127141 _requestToken ( ) {
128142 let url = `${ this . _config . basePath } ${ TOKEN_PATH } ` ;
129143 let clientId = this . _config . clientId ;
0 commit comments