1

We are using Nylas api to get Access token for different type of Email account like Gmail, Outlook.. But We couldn't authenticate for Gmail.

        let myURL = URL(string: getNylasAuthUrl())
        let userAgent = getUserAgentParams()
        webView.customUserAgent = userAgent
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)

got below error

enter image description here

Finally found a way, by setting User-Agent, we could do authentication for gmail from post

Tried below User-agents but didn't help

let userAgent =  "Mozilla/5.0 (Apple \(Utils.getDeviceModel()) ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
let userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
let userAgent = "Mozilla/5.0 (Google) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
Mani
  • 17,549
  • 13
  • 79
  • 100

1 Answers1

2

Finally, I found the working user-agent.

    let userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X)
AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14F89 Safari/602.1"

If you want to Google auth via Webview, use this user-agent especially for getting access token.

Mani
  • 17,549
  • 13
  • 79
  • 100