[GH-ISSUE #508] oauthswift with facebook app #335

Closed
opened 2026-03-03 16:47:48 +03:00 by kerem · 6 comments
Owner

Originally created by @sandeepk000 on GitHub (Jan 16, 2019).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/508

here is my code
with normal safari browser it is working but not with facebook app.i tried the process mentioned in native app thread which was opened 2 years before nut it didnt work.pls help

let oauthswift = OAuth2Swift(
consumerKey: "167108074192100", // [1] Enter google app settings
consumerSecret: "", // No secret required
authorizeUrl: "https://www.facebook.com/dialog/oauth",
accessTokenUrl: "https://graph.facebook.com/oauth/access_token",
responseType: "token"
)

var isFacebookAppInstalled: Bool = {
    let appUrl = URL(string: "fbauth2://app")
    return UIApplication.shared.canOpenURL(appUrl!)
}()

oauthswift.allowMissingStateCheck = true
oauthswift.authorizeURLHandler = NativeAppHandler.sharedInstance
let state = generateState(withLength: 20)
guard let rwURL = URL(string:"fbauth2://authorize?response_type=token&client_id=167108074192100&redirect_uri=fb167108074192100://oauth-callback") else { return }
//https://graph.facebook.com/oauth/authorize?response_type=token&client_id=167108074192100&redirect_uri=fb167108074192100://oauth-callback

let _ = oauthswift.authorize(withCallbackURL: rwURL, scope: "public_profile", state: state, success: { (credential, response, parameters) in
    print("\(credential)\(response)\(parameters)")
    let _ = oauthswift.client.get(
        "https://graph.facebook.com/me?",
        parameters: ["fields": "id, name, first_name, last_name, email"],
        success: { response in
            let dataString = response.string!
            print(dataString)
    }, failure: { error in
        print(error)
    })

}) { (error) in
    self.presentAlert("error", message: error.localizedDescription)
}

class NativeAppHandler: OAuthSwiftURLHandlerType {
public static var sharedInstance : NativeAppHandler = NativeAppHandler()

@objc open func handle(_ url: URL) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
// Fallback on earlier versions
}
}
}

I got this message in webview even i want to open facebook app i got this webview only:
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.

Originally created by @sandeepk000 on GitHub (Jan 16, 2019). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/508 here is my code with normal safari browser it is working but not with facebook app.i tried the process mentioned in native app thread which was opened 2 years before nut it didnt work.pls help let oauthswift = OAuth2Swift( consumerKey: "167108074192100", // [1] Enter google app settings consumerSecret: "", // No secret required authorizeUrl: "https://www.facebook.com/dialog/oauth", accessTokenUrl: "https://graph.facebook.com/oauth/access_token", responseType: "token" ) var isFacebookAppInstalled: Bool = { let appUrl = URL(string: "fbauth2://app") return UIApplication.shared.canOpenURL(appUrl!) }() oauthswift.allowMissingStateCheck = true oauthswift.authorizeURLHandler = NativeAppHandler.sharedInstance let state = generateState(withLength: 20) guard let rwURL = URL(string:"fbauth2://authorize?response_type=token&client_id=167108074192100&redirect_uri=fb167108074192100://oauth-callback") else { return } //https://graph.facebook.com/oauth/authorize?response_type=token&client_id=167108074192100&redirect_uri=fb167108074192100://oauth-callback let _ = oauthswift.authorize(withCallbackURL: rwURL, scope: "public_profile", state: state, success: { (credential, response, parameters) in print("\(credential)\(response)\(parameters)") let _ = oauthswift.client.get( "https://graph.facebook.com/me?", parameters: ["fields": "id, name, first_name, last_name, email"], success: { response in let dataString = response.string! print(dataString) }, failure: { error in print(error) }) }) { (error) in self.presentAlert("error", message: error.localizedDescription) } class NativeAppHandler: OAuthSwiftURLHandlerType { public static var sharedInstance : NativeAppHandler = NativeAppHandler() @objc open func handle(_ url: URL) { if #available(iOS 10.0, *) { UIApplication.shared.open(url, options: [:], completionHandler: nil) } else { // Fallback on earlier versions } } } I got this message in webview even i want to open facebook app i got this webview only: 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.
kerem closed this issue 2026-03-03 16:47:48 +03:00
Author
Owner

@phimage commented on GitHub (Jan 16, 2019):

Stop posting new issue

<!-- gh-comment-id:454719160 --> @phimage commented on GitHub (Jan 16, 2019): Stop posting new issue
Author
Owner

@sandeepk000 commented on GitHub (Jan 16, 2019):

can u give me ur chat number or anything? i want some info about how to access fb app


From: Eric Marchand notifications@github.com
Sent: Wednesday, January 16, 2019 3:25 PM
To: OAuthSwift/OAuthSwift
Cc: Kunusoth Sandeep; Author
Subject: Re: [OAuthSwift/OAuthSwift] oauthswift with facebook app (#508)

Closed #508https://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOAuthSwift%2FOAuthSwift%2Fissues%2F508&data=02%7C01%7CKunusoth.Sandeep%40kpit.com%7C1538d5682ee540483f4608d67b98b1d2%7C3539451eb46e4a26a242ff61502855c7%7C0%7C0%7C636832293093685579&sdata=BLurUmXYY%2F18h19wzQWwzojAw8JNilhlOFPrOaWmm08%3D&reserved=0.

You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOAuthSwift%2FOAuthSwift%2Fissues%2F508%23event-2076922421&data=02%7C01%7CKunusoth.Sandeep%40kpit.com%7C1538d5682ee540483f4608d67b98b1d2%7C3539451eb46e4a26a242ff61502855c7%7C0%7C0%7C636832293093685579&sdata=2KMaW%2B1vVdW4vb%2FsGv%2BTT%2BZO%2Bm9YNll8UY%2BQ%2B4vXDmY%3D&reserved=0, or mute the threadhttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAsEbGdo2kY7lYz8G4aTt-G5brGn_Seraks5vDvb4gaJpZM4aCsO8&data=02%7C01%7CKunusoth.Sandeep%40kpit.com%7C1538d5682ee540483f4608d67b98b1d2%7C3539451eb46e4a26a242ff61502855c7%7C0%7C0%7C636832293093685579&sdata=hjk5ZxVljUVhlcGriRM0vcwjgAo3TG%2Bj%2FaLDZm39RkQ%3D&reserved=0.

This message contains information that may be privileged or confidential and is the property of the KPIT Technologies Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Technologies Ltd. does not accept any liability for virus infected mails.

<!-- gh-comment-id:454719711 --> @sandeepk000 commented on GitHub (Jan 16, 2019): can u give me ur chat number or anything? i want some info about how to access fb app ________________________________ From: Eric Marchand <notifications@github.com> Sent: Wednesday, January 16, 2019 3:25 PM To: OAuthSwift/OAuthSwift Cc: Kunusoth Sandeep; Author Subject: Re: [OAuthSwift/OAuthSwift] oauthswift with facebook app (#508) Closed #508<https://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOAuthSwift%2FOAuthSwift%2Fissues%2F508&data=02%7C01%7CKunusoth.Sandeep%40kpit.com%7C1538d5682ee540483f4608d67b98b1d2%7C3539451eb46e4a26a242ff61502855c7%7C0%7C0%7C636832293093685579&sdata=BLurUmXYY%2F18h19wzQWwzojAw8JNilhlOFPrOaWmm08%3D&reserved=0>. - You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<https://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOAuthSwift%2FOAuthSwift%2Fissues%2F508%23event-2076922421&data=02%7C01%7CKunusoth.Sandeep%40kpit.com%7C1538d5682ee540483f4608d67b98b1d2%7C3539451eb46e4a26a242ff61502855c7%7C0%7C0%7C636832293093685579&sdata=2KMaW%2B1vVdW4vb%2FsGv%2BTT%2BZO%2Bm9YNll8UY%2BQ%2B4vXDmY%3D&reserved=0>, or mute the thread<https://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAsEbGdo2kY7lYz8G4aTt-G5brGn_Seraks5vDvb4gaJpZM4aCsO8&data=02%7C01%7CKunusoth.Sandeep%40kpit.com%7C1538d5682ee540483f4608d67b98b1d2%7C3539451eb46e4a26a242ff61502855c7%7C0%7C0%7C636832293093685579&sdata=hjk5ZxVljUVhlcGriRM0vcwjgAo3TG%2Bj%2FaLDZm39RkQ%3D&reserved=0>. This message contains information that may be privileged or confidential and is the property of the KPIT Technologies Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Technologies Ltd. does not accept any liability for virus infected mails.
Author
Owner

@phimage commented on GitHub (Jan 16, 2019):

Nope, I do no work for you
Please read github term and condition or I will report abuse from you

And read me, go ask your question not on github please

<!-- gh-comment-id:454720220 --> @phimage commented on GitHub (Jan 16, 2019): Nope, I do no work for you Please read github term and condition or I will report abuse from you And read me, go ask your question not on github please
Author
Owner

@sandeepk000 commented on GitHub (Jan 16, 2019):

how can u tell like that this is very important

<!-- gh-comment-id:454720662 --> @sandeepk000 commented on GitHub (Jan 16, 2019): how can u tell like that this is very important
Author
Owner

@sandeepk000 commented on GitHub (Jan 16, 2019):

if user everytime gets to browser its not good experience.please help

<!-- gh-comment-id:454720827 --> @sandeepk000 commented on GitHub (Jan 16, 2019): if user everytime gets to browser its not good experience.please help
Author
Owner

@sandeepk000 commented on GitHub (Jan 16, 2019):

give me some way to go to facebook app please

<!-- gh-comment-id:454721037 --> @sandeepk000 commented on GitHub (Jan 16, 2019): give me some way to go to facebook app please
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#335
No description provided.