instagram-web-api: 403 - API has been deprecated
I’m on 2.0.1 by installing straight from the master branch (as suggested by #97), but I’m getting a new error when I try to upload something. My code for login works (doesn’t throw any errors), just not uploading.
My code:
async function loginIG() {
console.log('loginIG: logging in');
try {
let response = await ig.login();
if (!response.authenticated) {
console.log('loginIG: failed to login');
throw null;
}
const profile = await ig.getProfile();
console.log(`loginIG: logged in as: ${profile.username}`);
} catch (e) {
let json = JSON.parse(e.message.substring(6));
console.log(json.message);
if (json.message == 'checkpoint_required') {
await doChallengeIG(json.checkpoint_url);
}
}
}
async function uploadIG(uri) {
console.log(`uploadIG: uploading: ${uri}`);
let media;
try {
media = await ig.uploadPhoto({
photo: uri,
caption: '...'});
console.log(`uploadIG: upload function complete`);
return `https:\\www.instagram.com/p/${media.media.code}/`;
} catch (e) {
console.log(`uploadIG: error`);
console.log(e);
}
}
Error:
{ StatusCodeError: 403 - {"message":"API has been deprecated.","status":"fail"}
at new StatusCodeError (D:\Project Files\DW\urmomeverything\node_modules\request-promise-core\lib\errors.js:32:15)
at Request.plumbing.callback (D:\Project Files\DW\urmomeverything\node_modules\request-promise-core\lib\plumbing.js:104:33)
at Request.RP$callback [as _callback] (D:\Project Files\DW\urmomeverything\node_modules\request-promise-core\lib\plumbing.js:46:31)
at Request.self.callback (D:\Project Files\DW\urmomeverything\node_modules\request\request.js:185:22)
at Request.emit (events.js:189:13)
at Request.<anonymous> (D:\Project Files\DW\urmomeverything\node_modules\request\request.js:1161:10)
at Request.emit (events.js:189:13)
at IncomingMessage.<anonymous> (D:\Project Files\DW\urmomeverything\node_modules\request\request.js:1083:12)
at Object.onceWrapper (events.js:277:13)
at IncomingMessage.emit (events.js:194:15)
name: 'StatusCodeError',
statusCode: 403,
message:
'403 - {"message":"API has been deprecated.","status":"fail"}',
error: { message: 'API has been deprecated.', status: 'fail' },
options:
{ baseUrl: 'https://www.instagram.com',
uri: '/create/upload/photo/',
headers:
{ 'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0',
'Accept-Language': 'en-US',
'X-Instagram-AJAX': 1,
'X-Requested-With': 'XMLHttpRequest',
Referer: 'https://www.instagram.com',
'X-CSRFToken': '8pNMSedcsIWiztVfWOUdEP3Ic2hXJpLh' },
jar: RequestJar { _jar: [CookieJar] },
json: true,
formData:
{ upload_id: '1563644337393',
photo: [ReadStream],
media_type: '1' },
method: 'POST',
callback: [Function: RP$callback],
transform: undefined,
simple: true,
resolveWithFullResponse: false,
transform2xxOnly: false },
response:
IncomingMessage {
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: true,
endEmitted: true,
reading: false,
sync: false,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
paused: false,
emitClose: true,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: false,
_events:
[Object: null prototype] {
end: [Array],
close: [Array],
data: [Function],
error: [Function] },
_eventsCount: 4,
_maxListeners: undefined,
socket:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'www.instagram.com',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 8,
connecting: false,
_hadError: false,
_handle: [TLSWrap],
_parent: null,
_host: 'www.instagram.com',
_readableState: [ReadableState],
readable: true,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [ClientRequest],
[Symbol(res)]: [TLSWrap],
[Symbol(asyncId)]: 486,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(connect-options)]: [Object] },
connection:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'www.instagram.com',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 8,
connecting: false,
_hadError: false,
_handle: [TLSWrap],
_parent: null,
_host: 'www.instagram.com',
_readableState: [ReadableState],
readable: true,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [ClientRequest],
[Symbol(res)]: [TLSWrap],
[Symbol(asyncId)]: 486,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(connect-options)]: [Object] },
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers:
{ server: 'nginx',
date: 'Sat, 20 Jul 2019 17:38:59 GMT',
'content-type': 'application/json; charset=utf-8',
vary: 'Accept-Language, Cookie',
'content-language': 'en',
'strict-transport-security': 'max-age=31536000',
'cache-control': 'private, no-cache, no-store, must-revalidate',
pragma: 'no-cache',
expires: 'Sat, 01 Jan 2000 00:00:00 GMT',
'x-frame-options': 'SAMEORIGIN',
'content-security-policy':
'report-uri https://www.instagram.com/security/csp_report/; default-src \'self\' https://www.instagram.com; img-src https: data: blob:; font-src https: data:; media-src \'self\' blob: https://www.instagram.com https://*.cdninstagram.com https://*.fbcdn.net; manifest-src \'self\' https://www.instagram.com; script-src \'self\' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://*.cdninstagram.com wss://www.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net \'unsafe-inline\' \'unsafe-eval\' blob:; style-src \'self\' https://*.www.instagram.com https://www.instagram.com \'unsafe-inline\'; connect-src \'self\' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://graph.instagram.com https://*.graph.instagram.com https://*.cdninstagram.com https://api.instagram.com wss://www.instagram.com wss://edge-chat.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net chrome-extension://boadgeojelhgndaghljhdicfkmllpafd blob:; worker-src \'self\' blob: https://www.instagram.com; frame-src \'self\' https://instagram.com https://www.instagram.com https://staticxx.facebook.com https://www.facebook.com https://web.facebook.com https://connect.facebook.net https://m.facebook.com; object-src \'none\'; upgrade-insecure-requests',
'x-content-type-options': 'nosniff',
'x-xss-protection': '0',
'x-aed': '9',
'set-cookie': [Array],
'x-fb-trip-id': '1679558926',
connection: 'close',
'content-length': '57' },
rawHeaders:
[ 'Server',
'nginx',
'Date',
'Sat, 20 Jul 2019 17:38:59 GMT',
'Content-Type',
'application/json; charset=utf-8',
'Vary',
'Accept-Language, Cookie',
'Content-Language',
'en',
'Strict-Transport-Security',
'max-age=31536000',
'Cache-Control',
'private, no-cache, no-store, must-revalidate',
'Pragma',
'no-cache',
'Expires',
'Sat, 01 Jan 2000 00:00:00 GMT',
'X-Frame-Options',
'SAMEORIGIN',
'content-security-policy',
'report-uri https://www.instagram.com/security/csp_report/; default-src \'self\' https://www.instagram.com; img-src https: data: blob:; font-src https: data:; media-src \'self\' blob: https://www.instagram.com https://*.cdninstagram.com https://*.fbcdn.net; manifest-src \'self\' https://www.instagram.com; script-src \'self\' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://*.cdninstagram.com wss://www.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net \'unsafe-inline\' \'unsafe-eval\' blob:; style-src \'self\' https://*.www.instagram.com https://www.instagram.com \'unsafe-inline\'; connect-src \'self\' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://graph.instagram.com https://*.graph.instagram.com https://*.cdninstagram.com https://api.instagram.com wss://www.instagram.com wss://edge-chat.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net chrome-extension://boadgeojelhgndaghljhdicfkmllpafd blob:; worker-src \'self\' blob: https://www.instagram.com; frame-src \'self\' https://instagram.com https://www.instagram.com https://staticxx.facebook.com https://www.facebook.com https://web.facebook.com https://connect.facebook.net https://m.facebook.com; object-src \'none\'; upgrade-insecure-requests',
'X-Content-Type-Options',
'nosniff',
'X-XSS-Protection',
'0',
'x-aed',
'9',
'Set-Cookie',
'csrftoken=8pNMSedcsIWiztVfWOUdEP3Ic2hXJpLh; Domain=.instagram.com; expires=Sat, 18-Jul-2020 17:38:59 GMT; Max-Age=31449600; Path=/; Secure',
'Set-Cookie',
'rur=ATN; Domain=.instagram.com; HttpOnly; Path=/; Secure',
'X-FB-TRIP-ID',
'1679558926',
'Connection',
'close',
'Content-Length',
'57' ],
trailers: {},
rawTrailers: [],
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 403,
statusMessage: 'Forbidden',
client:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'www.instagram.com',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 8,
connecting: false,
_hadError: false,
_handle: [TLSWrap],
_parent: null,
_host: 'www.instagram.com',
_readableState: [ReadableState],
readable: true,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [ClientRequest],
[Symbol(res)]: [TLSWrap],
[Symbol(asyncId)]: 486,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(connect-options)]: [Object] },
_consuming: true,
_dumped: false,
req:
ClientRequest {
_events: [Object],
_eventsCount: 5,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [TLSSocket],
connection: [TLSSocket],
_header:
'POST /create/upload/photo/ HTTP/1.1\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0\r\nAccept-Language: en-US\r\nX-Instagram-AJAX: 1\r\nX-Requested-With: XMLHttpRequest\r\nReferer: https://www.instagram.com\r\nX-CSRFToken: 8pNMSedcsIWiztVfWOUdEP3Ic2hXJpLh\r\nhost: www.instagram.com\r\ncookie: ig_cb=1; csrftoken=8pNMSedcsIWiztVfWOUdEP3Ic2hXJpLh; rur=FTW; mid=XTNRrQALAAEJ_D4_0rHQcyszL2cf; shbid=11795; shbts=1563644334.9783514; ds_user_id=13525154342; sessionid=13525154342%3AxAY4PKagPsUHpH%3A13\r\naccept: application/json\r\ncontent-type: multipart/form-data; boundary=--------------------------610008841723173528087146\r\ncontent-length: 106933\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Agent],
socketPath: undefined,
timeout: undefined,
method: 'POST',
path: '/create/upload/photo/',
_ended: true,
res: [Circular],
aborted: undefined,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(isCorked)]: false,
[Symbol(outHeadersKey)]: [Object] },
request:
Request {
_events: [Object],
_eventsCount: 5,
_maxListeners: undefined,
uri: [Url],
headers: [Object],
formData: [Object],
method: 'POST',
readable: true,
writable: true,
explicitMethod: true,
_qs: [Querystring],
_auth: [Auth],
_oauth: [OAuth],
_multipart: [Multipart],
_redirect: [Redirect],
_tunnel: [Tunnel],
_rp_resolve: [Function],
_rp_reject: [Function],
_rp_promise: [Promise],
_rp_callbackOrig: undefined,
callback: [Function],
_rp_options: [Object],
setHeader: [Function],
hasHeader: [Function],
getHeader: [Function],
removeHeader: [Function],
localAddress: undefined,
pool: {},
dests: [],
__isRequestRequest: true,
_callback: [Function: RP$callback],
proxy: null,
tunnel: true,
setHost: true,
originalCookieHeader: undefined,
_jar: [RequestJar],
port: 443,
host: 'www.instagram.com',
_form: [FormData],
path: '/create/upload/photo/',
_json: true,
httpModule: [Object],
agentClass: [Function],
agent: [Agent],
ntick: true,
src: [FormData],
_started: true,
href: 'https://www.instagram.com/create/upload/photo/',
req: [ClientRequest],
response: [Circular],
originalHost: 'www.instagram.com',
originalHostHeaderName: 'host',
responseContent: [Circular],
_destdata: true,
_ended: true,
_callbackCalled: true },
toJSON: [Function: responseToJSON],
caseless: Caseless { dict: [Object] },
body: { message: 'API has been deprecated.', status: 'fail' } } }
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 4
- Comments: 15
@blaxbla123 i try understand but documentation there unreadable