Comments (7)
It's possible now to pass your own request headers or turn the default user-agent off.
It's accessible from: HttpSettings.shared.useFakeUserAgent = false
Note: a user agent is automatically provided as part of the default session configuration but it's awful, better to use your own customized one.
Read this link for more details
from swiftyinsta.
When I set useFakeUserAgent = false
and try to login, I get error 'CSRF token missing or incorrect'. Please help :)
from swiftyinsta.
I took a look and it seems Instagram validates your user-agent before giving you a CSRF token.
User-Agent should follow this format:
Instagram [AppVersion] [OS] ([OSVersion]/[OSRelease]; [DPI]; [DeviceResolution]; [DeviceBrand]; [DeviceModel]; [DeviceModel]; [DeviceModelBoot]; [UserLocale]; [Facebook User-Agent escape string])
Instagram 78.0.0.9.103 Android (21/5.0.2; 480dpi; 1080x1776; Sony; C6603; C6603; qcom; ru_RU; 95414346)
It takes time to create a random user-agent generator but I think I will probably implement it.
There is a list of devices with info which you can create your own customized user-agent for now.
take a look at AndroidDeviceGenerator.swift
from swiftyinsta.
for now, you can use CustomUserAgent
model to create your own user-agent like this:
let userAgent = CustomUserAgent(apiVersion: "79.0.0.0", osName: "iOS", osVersion: "12", osRelease: "1.4", dpi: "458", resolution: "2688x1242", company: "Apple", model: "iPhone11,2", modem: "intel", locale: "en_US", fbCode: "95414346")
HttpSettings.shared.addValue(userAgent.toString(), forHTTPHeaderField: "User-Agent")
If there is no further question, please close the issue.
from swiftyinsta.
@TheM4hd1
FYI:
let userAgent = CustomUserAgent(apiVersion: "79.0.0.0", osName: "iOS", osVersion: "12", osRelease: "1.4", dpi: "458", resolution: "2688x1242", company: "Apple", model: "iPhone11,2", modem: "intel", locale: "en_US", fbCode: "95414346")
won't work outside of framework scope because synthesized initializer is set to internal access by default
from swiftyinsta.
use the latest update.
As you see the initializer is
public
from swiftyinsta.
@cprovatas
Here is a function for creating user-agent base on device.
public static func build() {
let device = HandlerSettings.shared.device!
let apiVersion = "85.0.0.21.100"
let os = "Android"
let version = device.frimwareFingerprint.split(separator: "/")[2].split(separator: ":")[1]
let androidVersion = AndroidVersion.fromString(versionString: String(version))
if let androidVersion = androidVersion {
let _androidVersion = androidVersion.versionNumber.split(separator: ".").first!
let _androidRelease = androidVersion.versionNumber.split(separator: ".").last!
let dpi = "640dpi"
let res = "1440x2560"
let company = device.deviceBrand
let model = device.deviceModel
let modem = device.deviceModelBoot
let locale = "en-US"
let fbCode = "146536611"
let agent = CustomUserAgent(apiVersion: apiVersion, osName: os, osVersion: String(_androidVersion), osRelease: String(_androidRelease), dpi: dpi, resolution: res, company: company, model: model, modem: modem, locale: locale, fbCode: fbCode)
HttpSettings.shared.addValue(agent.toString(), forHTTPHeaderField: Headers.HeaderUserAgentKey)
}
}
But I doubt that the issue is relevant to user-agent.
from swiftyinsta.
Related Issues (20)
- LoginWebViewController can't login HOT 5
- Get isFollowedByYou Property while fetch users own followers HOT 1
- PaginationParameters.nextMaxId always nil when querying Inbox HOT 5
- Maintainers needed
- Test HOT 1
- Test HOT 2
- how to parse response? HOT 1
- how can get account activity list in swiftyinsta ? HOT 1
- Modifying thread_message_limit when requesting the Inbox HOT 1
- handler.requests is nil HOT 4
- Pagination HOT 2
- follower count HOT 1
- pagination HOT 1
- Enum cases with associated values cannot be marked potentially unavailable with '@available' HOT 3
- fetch followers issue HOT 1
- About Download Reels Using Copy Link HOT 1
- Authorization has stopped working! HOT 3
- login completion not working HOT 1
- New maintainers or fork? HOT 2
- LoginWebViewController can't login, no return sessionid HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftyinsta.