신속하게 oAuth 2.0을 사용하여 linkedin Api에 작업 중입니다. 가장 큰 문제는 access_token
을 얻은 후 UIWebView
에 쿠키를 쓰지 않았기 때문입니다. 나는하지 /feed
페이지를 access_token
을 받고 있지만, 디스플레이 로그인 페이지 후이`oAuth를 사용하여 Linkedin 로그인 1.0a
oginWebView.loadRequest(URLRequest(url: URL(string : "https://www.instagram.com/")!))
을 시도했다. 내 앱용 쿠키가 필요해. 나는 많은 게시물을 점검했지만 oAuth 1.0a에서 인증을위한 적절한 솔루션을 얻지 못했습니다. Instagram oauth
을 사용 중이며 쿠키도 제공합니다. 나는 oAuth 1.0
으로 생각한다. 나는 오아시스에 대해 많은 지식을 가지고 있지 않았다.
누구든지 oAuth 1.0a를 사용하여 webview에서 링크 인 인증의 간단한 로그인 예 (신속, 객관적인 -C)를 제공 할 수 있습니까? 또는 쿠키 저장을위한 다른 솔루션. 또는 내가 어떻게 linkedin 코드에 사용할 수 있습니다. 감사합니다. .
oAuth 1.0 Sample
struct INSTAGRAM_IDS {
static let INSTAGRAM_AUTHURL = "https://api.instagram.com/oauth/authorize/"
static let INSTAGRAM_APIURl = "https://api.instagram.com/v1/users/"
static let INSTAGRAM_CLIENT_ID = ""
static let INSTAGRAM_CLIENTSERCRET = ""
static let INSTAGRAM_REDIRECT_URI = ""
static let INSTAGRAM_ACCESS_TOKEN = "access_token"
static let INSTAGRAM_SCOPE = "likes+comments+relationships+public_content+follower_list"
}
func unSignedRequest() {
let authURL = String(format: "%@?client_id=%@&redirect_uri=%@&response_type=token&scope=%@&DEBUG=True", arguments: [INSTAGRAM_IDS.INSTAGRAM_AUTHURL,INSTAGRAM_IDS.INSTAGRAM_CLIENT_ID,INSTAGRAM_IDS.INSTAGRAM_REDIRECT_URI, INSTAGRAM_IDS.INSTAGRAM_SCOPE ])
let urlRequest = URLRequest.init(url: URL.init(string: authURL)!)
loginWebView.loadRequest(urlRequest)
}
func checkRequestForCallbackURL(request: URLRequest) -> Bool {
let requestURLString = (request.url?.absoluteString)! as String
if requestURLString.hasPrefix(INSTAGRAM_IDS.INSTAGRAM_REDIRECT_URI) {
print(requestURLString, "RedirectURL")
let range: Range<String.Index> = requestURLString.range(of: "#access_token=")!
handleAuth(authToken: requestURLString.substring(from: range.upperBound))
self.dismiss(animated: true, completion: nil)
return false;
}
return true
}
func handleAuth(authToken: String) {
print("Instagram authentication token ==", authToken)
downloadImage(url: URL(string: "https://api.instagram.com/v1/users/self?access_token=\(authToken)")!)
}
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
return checkRequestForCallbackURL(request: request)
}