mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[GH-ISSUE #406] Facebook example #261
Labels
No labels
bug
cocoapod
duplicate
enhancement
feature-request
help wanted
help wanted
invalid
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/OAuthSwift#261
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dtomicAZ on GitHub (Sep 4, 2017).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/406
Description:
I have problem with Facebook login using OAuthSwift.
I've found this "Handle a specific URL into delegate":
https://github.com/OAuthSwift/OAuthSwift/wiki/API-with-only-HTTP-scheme-into-callback-URL
I don't know how to setup internal webview, can someone give me step by step, or some example, thank you.
OAuth Provider
Facebook
OAuth Version:
Version 2
OS (Please fill the version) :
iOS :
Installation method:
CocoaPods
Library version:
v1.1.0
Xcode version:
8.3.3 (Swift 3.1)
@phimage commented on GitHub (Sep 4, 2017):
You can extends
OAuthWebViewControllerand set
oauthswift.authorizeURLHandler=...in demo there is an example of web view controller
https://github.com/OAuthSwift/OAuthSwift/blob/master/Demo/Common/WebViewController.swift
@dtomicAZ commented on GitHub (Sep 4, 2017):
@phimage Thank you for fast respond.
Please if you can tell me what modifications in WebViewController I need make ?
My URL_scheme name is autoworld.
Also what should be my callback url in authorize method ?
@phimage commented on GitHub (Sep 4, 2017):
If you use a web view delegate you never use a custom url scheme
If you read this page https://github.com/OAuthSwift/OAuthSwift/wiki/API-with-only-HTTP-scheme-into-callback-URL it's because the callback url must an HTTP one, not a custom one
You can see in the page
YOUR_URL, you can put any http url that facebook allowhttps://autoworld/callback
@dtomicAZ commented on GitHub (Sep 5, 2017):
@phimage Thank you for help.
I have another problems.
Here is my code:
func doOAuthFacebook() {
let oauthswift = OAuth2Swift(
consumerKey: "XXXXX",
consumerSecret: "XXXXX",
authorizeUrl: "https://www.facebook.com/dialog/oauth",
accessTokenUrl: "https://graph.facebook.com/oauth/access_token",
responseType: "code"
)
}
I got this message in webview:
Can't Load ULR: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.
I tried add autoworld.org domain in the Apps domain field on Facebook panel, but I got this error:
App domains must match the domain of the Facebook Web Games URL (https), Mobile Site URL, Unity Binary URL, Site URL or Secure Page Tab URL. Please correct these domains: autoworld.org
What should I do ? Thank you for your time.
@phimage commented on GitHub (Sep 5, 2017):
add https://autoworld.org
Then do not do that
oauthswift object will be released from memory, put the object into class variable
@dtomicAZ commented on GitHub (Sep 5, 2017):
@phimage
I tried to add https://autoworld.org but still Facebook give me same error:
App domains must match the domain of the Facebook Web Games URL (https), Mobile Site URL, Unity Binary URL, Site URL or Secure Page Tab URL. Please correct these domains: autoworld.org
@phimage commented on GitHub (Sep 5, 2017):
please make screenshot
and give facebook documentation link about configuring the http callback url
@dtomicAZ commented on GitHub (Sep 5, 2017):
@phimage
It'l looks like I had to add website platform. After that I am allowed to set App Domains.
Now that is ok.
I get this screen in mobile app:

There is Cookies header on top, and there is no Done button.
Should it be like this ?
Do I need to add manually navigation bar so User can cancel this process?
@dtomicAZ commented on GitHub (Sep 5, 2017):
@phimage
This is now working.
This is my viewDidLoad of my OAuthFBWebViewController which extends OAuthWebViewController:
override func viewDidLoad() {
super.viewDidLoad()
}
func cancelClicked() {
self.dismissWebViewController()
}
Also I added this, so cookie header is not visible:
func webViewDidFinishLoad(_ webView: UIWebView) {
webView.stringByEvaluatingJavaScript(from: "document.getElementById('header-notices').style.display = 'none';")
}
Just one more question.
Is drawback of this Library that It can't recognise if user is already logged in Facebook with some of this methods (I mean with this Lib user will have to always input credentials):
-with native Facebook app,
-through Settings app,
@phimage commented on GitHub (Sep 5, 2017):
You can store the credential for next run
https://github.com/OAuthSwift/OAuthSwift/wiki/Store-credential
You cannot access info from settings or facebook app
for facebook app you must use facebook sdk or do some stuff with x-callbackurl
@dtomicAZ commented on GitHub (Sep 5, 2017):
@phimage
Ok, Thank you for your help.