simple_auth
simple_auth copied to clipboard
Instagram oAuth doesn't redirect in ios
I'm using it for Facebook and Instagram social login. Facebook works perfectly in ios and android both. But Instagram works only in android , for iOS it's not dismissing the webview after successful login. I checked redirect URL is correct. Kindly help me in fixing the issue.
@Clancey can you please help
Without more information, it's impossible for me to tell you what to do. You should be able to debug it pretty easily by putting a break point here: https://github.com/Clancey/simple_auth/blob/master/simple_auth_flutter/ios/Classes/SFSafariAuthenticator.m#L105. or here: https://github.com/Clancey/simple_auth/blob/master/simple_auth_flutter/ios/Classes/WebAuthenticatorViewController.m#L81 (based on what type of view controller you are presenting). That is what is called when iOS gets a URL back from the the webviews
Hi @Clancey & @parulgarg004
I'm trying to implement Instagram login.. the code is the following
var api = new simpleAuth.InstagramApi("instagram", AppConstants.instagramAppId, AppConstants.instagramAppSecret, "com.dijiti.ppl:/redirct", scopes: [
"user_profile",
"user_media"
]);
var request = new simpleAuth.Request(simpleAuth.HttpMethod.Get, "https://api.instagram.com/oauth/authorize");
var userInfo = await api.send<UserInfo>(request);
on instagram developer page i can only set https redirects...
so i made really really musch tests but this is not working... redirect url isn't correct and i cannot manage to make it works.. could you give me some advice? thanks!
@Clancey & @parulgarg004, Instagram only accepts redirect URLs starting with https. @Clancey. Maybe we could leverage https://pub.dev/packages/uni_links?
@PatrickGhara see the above. If you need more information, I just documented the process here: https://blog.maskys.com/using-the-instagram-basic-display-api-in-flutter/
Hi @MaskyS @Clancey
I have the same problem as @parulgarg004 . The user is not redirected back to my app on iOS and gets stuck in the webview.
I have successfully added the uni_link package and I could open my app via this command: /usr/bin/xcrun simctl openurl booted "https://MY_URI"
My code for the Instagram account verification looks like this:
final simpleAuth.InstagramApi instagramApi = simpleAuth.InstagramApi( "instagram", "CLIENT_ID", "CLIENT_SECRET", "https://MY_URI", scopes: [ 'user_profile' ], ); simpleAuth.OAuthAccount account = await instagramApi.authenticate(); var instagramUserResponse = await Dio(BaseOptions(baseUrl: 'https://graph.instagram.com')).get( '/me', queryParameters: { "fields": "username,id", "access_token": account.token, }, );
If I change the redirectUrl and set it to google.com for example, the webview successfully redirects me to this website.
My Runner.entitlements file contains the following entry:
<key>com.apple.developer.associated-domains</key> <array> <string>applinks:MY_URI</string> </array>
I hope that one of you has an idea how to fix this.
@daniel-possienke Did you find the way to fix this problem?
@daniel-possienke @MaskyS @Clancey running into the same issue.
xcrun simctl openurl booted "https://MY_URI"
redirect me to the app just fine.
In the app, when the redirect URI is set to "https://MY_URI" the webview stay open, blank with no error message. Dismissing it cancel the login.
In swift, those are not triggered :
override func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
NSLog("APP [deep link]: Open URI-scheme for iOS 9 and above")
return SimpleAuthFlutterPlugin.check(url)
}
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
NSLog("APP [deep link]: Open URI-scheme options")
return SimpleAuthFlutterPlugin.check(url)
}
In the other hand, this is triggered, but there is no URL to provide SimpleAuthFlutterPlugin :
// Reports app open from deep link for iOS 10 or later
override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
NSLog("APP [deep link]: continue userActivity")
return SimpleAuthFlutterPlugin.check(URL(string:"https://MY_URI"))
}
I'm available on Zoom, Discord, GoogleVoice,... if needed to help resolve this :)
Edit : After some more tests, the code below does log me in but the Safari View Controller stay open on the blank page (flutter: Bad state: Future already completed).
override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
NSLog("APP [deep link]: continue userActivity")
guard let urlString = userActivity.webpageURL?.absoluteString else {
return false
}
return SimpleAuthFlutterPlugin.check(URL(string:urlString))
}
Getting closer there.
FYI, Firebase deeplink seem the receive the code first, but don't know how to handle it.
8.9.0 - [Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: {
code = "AQDe1j7gGNt3w0LoMbKBmyTH29xavDbRyvla1-w_k6Eap_EbbRX0VcZiilkOaC6N8B8ah3a-YsqeJKrG224Af58nMZCSQCilUMR4vRkuhwgbseikufghvrewiuyvgbvuzrAwDYn0-WAv1zqyW8uew7m5wOLQa1WY6nvaHtz7m--Gvj_yGHZomFGsSKogXfV1atfX_XZ1w5xFPLCyNdsSOlUlKfE4LqWWo8IPzK-tfx9WTrBolrULobEOrkA";
}
@parulgarg004 @Clancey Did you find any solution for this? I am facing the same problem. Package version: simple_auth_flutter: ^2.0.11 Flutter version: 2.10.3 Dart version: 2.16.1
Thanks 🙏
@parulgarg004 @Clancey Did you find any solution for this? I am facing the same problem. Package version: simple_auth_flutter: ^2.0.11 Flutter version: 2.10.3 Dart version: 2.16.1
Thanks 🙏
same here... find any solution?
@daniel-possienke @MaskyS @Clancey running into the same issue.
xcrun simctl openurl booted "https://MY_URI"
redirect me to the app just fine. In the app, when the redirect URI is set to "https://MY_URI" the webview stay open, blank with no error message. Dismissing it cancel the login.In swift, those are not triggered :
override func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { NSLog("APP [deep link]: Open URI-scheme for iOS 9 and above") return SimpleAuthFlutterPlugin.check(url) } override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { NSLog("APP [deep link]: Open URI-scheme options") return SimpleAuthFlutterPlugin.check(url) }
In the other hand, this is triggered, but there is no URL to provide SimpleAuthFlutterPlugin :
// Reports app open from deep link for iOS 10 or later override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { NSLog("APP [deep link]: continue userActivity") return SimpleAuthFlutterPlugin.check(URL(string:"https://MY_URI")) }
I'm available on Zoom, Discord, GoogleVoice,... if needed to help resolve this :)
Edit : After some more tests, the code below does log me in but the Safari View Controller stay open on the blank page (flutter: Bad state: Future already completed).
override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { NSLog("APP [deep link]: continue userActivity") guard let urlString = userActivity.webpageURL?.absoluteString else { return false } return SimpleAuthFlutterPlugin.check(URL(string:urlString)) }
Getting closer there.
FYI, Firebase deeplink seem the receive the code first, but don't know how to handle it.
8.9.0 - [Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: { code = "AQDe1j7gGNt3w0LoMbKBmyTH29xavDbRyvla1-w_k6Eap_EbbRX0VcZiilkOaC6N8B8ah3a-YsqeJKrG224Af58nMZCSQCilUMR4vRkuhwgbseikufghvrewiuyvgbvuzrAwDYn0-WAv1zqyW8uew7m5wOLQa1WY6nvaHtz7m--Gvj_yGHZomFGsSKogXfV1atfX_XZ1w5xFPLCyNdsSOlUlKfE4LqWWo8IPzK-tfx9WTrBolrULobEOrkA"; }
find any solution? I'm 2 days stuck on this bug. When authorizing on Instagram on iOS the webview is not closed