Instagram redirect URI doesn't match or some time safari says "Cannot open because invalid address" + iOS native app - ios

I'm using this iOS Library https://github.com/crino/instagram-ios-sdk to login to instagram from my native app for sharing and getting feed from Instagram APIs. When i brought classes from this demo app to my project, here it is what happens:
Application successfully opens Authorization URL in safari and when i enter my credentials & authorize, it says "Safari cannot open address because its invalid" before redirecting to app or some time says "Redirect URI does not match registered URI".
Any help on this is appreciated.

You have to add URL scheme to your application's plist file, it's mentioned in short guide on github instragram page:
Make sure you've edited your application's .plist file properly, so that your applicaition binds to the ig[clientId]:// URL scheme (where [clientId] is your Instagram application CLIENT ID).
Here you'll find more information, see this article on TutsPlus: iOS SDK Working With URL Schemes

That error indicates that the URI you gave it is not handled by anything in the phone.
For example - the skype uri looks like skype:
IF skype is installed, it opens skype.
If skype is NOT installed, you get that same error.
You are either using the wrong URI (probably because you got the client-id wrong - do not include the [] in it), or, you do not have the Instagram app installed on your iOS device, or possibly you've messed with your instagram account and the app is not listening to that URI anymore.

Related

Safari cannot open the page because the address is invalid after successful uber oauth

I'm linking to the uber api authentication endpoints (/authorize and /token) via iOS and after a successful login, it returns "Safari cannot open the page because the address is invalid". I've narrowed this down to an iOS specific problem because the same react-native configuration works for Android.
I've tried a number of solutions.
Clear safari browsing history, web data, iPhone update, etc. Nothing has worked.
I believe URL Schemes under URL Types in info.plist has a pay here, but I'm struggling to wrap my head around what I need to put there.
Any thoughts?
Upon successful authentication, uber should return an access token for the user.

Safari error on login Microsoft account with oauth2

I have a a problem on a Nativescript 5.1.0 project with Angular 4, I use the API nativescript-oauth2, and it works fine for Facebook and Google, but when I try to Login into Microsoft it does not do very well.
I can enter the e-mail account and password, even the permission screen is shown, but in this one when I press YES it crashes.
The problem is because of the property redirect uri (urn:ietf:wg:oauth:2.0:oob) for the Microsoft configuration, when Safari receives the redirect uri, Safari crashes.
I read that can be solved with a delegate, but it already exists in the nativescript-oauth2.
And the android browser does not show the error but it does nothing.
Help me please!!
With Microsoft oAuth, it tries to open your app with an URL scheme. You might want to setup URL schemes in your app like it's showcased in demo app for Provider, iOS & Android

iOS deeplink (universal Link) through sub Domain

I have read a lot of articles regarding universal links but still i need to be clear regarding few things.
I have to add universal links to http://www.domain.com but due to certain reasons i will not be able to make my website SSL certified or even put apple-app-site-association with https in root folder. So I thought of doing this in a different way, i will put apple-app-site-association file in the root of a subdomain, lets say https://www.app.domain.com/apple-app-site-association
Then i will open every universal link with that subdomain whenever universal link is available and redirect https://www.app.domain.com to http://www.domain.com if universal link is not available.
Questions in my mind :-
apple says - file needs to be accessible via HTTPS—without any redirects—at https:///apple-app-site-association.
In this line what does apple mean by without any redirects ?
when apple does not find any universal link related to a particular URL, will it itself redirects it to safari.
Is this a safe way to add universal links or is it necessary to have our main domain on https or at-least apple-app-site-association on https
This should work fine. To explicitly answer your questions:
'Without redirects' means when iOS requests https://www.app.domain.com/apple-app-site-association, it must find the file at that address. You can't have a redirect of any kind (Javascript, 301, 302, etc)
If a URL is not valid for Universal Links because you didn't cover it using the inclusion rules in the apple-app-site-association file, it will be opened using Safari. If the URL is on another domain without a valid apple-app-site-association file (e.g., http://www.domain.com/), then it will also be opened in Safari.
Yes, it's fine. Definitely a workaround, but not unsafe.
You should also investigate a hosted deep linking service like Branch.io (full disclosure: I'm on the Branch team) or Firebase Dynamic Links. These will give you all of the same benefits (plus a bunch more flexibility, to be honest) without any of the setup headaches.
We experienced ways where a 302 on iOS works.
In general I fully agree that Apple officially does not seem to support any redirect.
The following cases have been tested on an iPhone 6 running iOS 11.
These cases work :
Website in Chrome on iOS: User clicks on link A and a 302 redirects him to a Universal link B.
Website in Safari on iOS: User clicks on link A and a 302 redirects him to a Universal link B.
Gmail App on iOS: User clicks on link in email and Gmail opens external Chrome browser, which opens a Google link which redirects to link A which redirects via 302 to Universal Link B. (this case works only if Chrome is installed and in Gmail Settings the user explicitly changed the default browser to Chrome)
These cases DO NOT work:
Apple Mail: User clicks on link A in email and external Safari is opened. 302 happens and opens Universal link B. Result: App does not open
Gmail App: User clicks on link A in email and Gmail inAppBrowser (probably WKWebview?) is opened. Gmail redirects EVERY link from an email over a google server, as a second step link A is opened (dont know via 302 or other method) then 302 happens and opens Universal link B. Result: App does not open
Unfortunately you can see that in some cases it does NOT work. As these cases, Apple Mail and Gmail on iOS are very important for most of us here, I think this is a showstopper and you should not use it.
We tested with Adjust links and therefore in cases where the app does not open Adjust opens the AppStore to download the app.
For all Adjust interested: We tested by opening a link https://app.adjust.com/... which has a 302 on the respective Universal link https://XXXXXXX.adj.st/... on which our app listens.

Oauth suddenly not working on iphone (with FS app installed only)

Our iphone app allows for sign in via Foursquare via oauth. It was working fine and recently stopped working.
The error we get is: Connecting Failure: Callback uri is not valid for this consumer.
HOWEVER, if the user does not have the foursquare app installed on their phone it works fine as before. It seems as if FS is now doing a redirect to handle the oauth inside the FS app and this fails when attempting to return to the originating application. Via safari it seems to work.
This is on ios 9.
Solutions?? Thanks!
We've changed to use a SafariViewController and this seems to force Foursquare to not to this strange in-app redirect, solving the issue. This is also Apple's preferred oauth method, so probably the way to go.
Still seems like a problem on the Foursquare side that they may want to address for others however. I'm closing this question. Thanks.
Where does your redirect URL point? If you want it to launch your app after completion you should point to the iTunes store (pre-iOS9) link for your app or the universal link (iOS9 onwards).
More information on redirects for the native foursquare app is available in the README here: https://github.com/foursquare/foursquare-ios-oauth/
How to create a universal link in iOS9 https://www.appsflyer.com/blog/how-to-set-up-ios-9-universal-links-for-your-app/
A callback url is a webpage loaded after your web app has been
verified. In this case, you need to specify a page for to send data to
after authentication
Double check your Foursquare credentials and update the callback uri to a valid link. Tutorial link
Please follow the below points, may be one resolves your issue:-
Enter the callback in foursquare account in addcallback methods. Then in your code add the call back to the provider before you authorize. (Reference here).
You're getting that error because the URL you're pointing your users to (foursquare.com/oauth2/...) includes a redirect_uri parameter that doesn't match with what you configured in your app's settings under https://foursquare.com/developers/apps. Make sure these match!

What's a redirect URI? how does it apply to iOS app for OAuth2.0?

Beginner programmer here, please pardon ignorance & explanations will be really nice :)
I've tried to read the tutorials for a certain OAuth 2.0 service, but I don't understand this redirect URI... in my particular context, let's say I'm trying to build an iPhone app that uses OAuth 2.0 for some service. I have an App ID that was generated, but i need to provide some sort of redirect URI to generate the API key.
Is this a URL that I'm supposed to host somewhere myself?? As the name suggests, I would think that the redirect URL is supposed to "redirect" someone somewhere. My only guess is that it's the URL a user is redirected to after they log in to the service.
However, even if that assumption is correct, I don't understand one other thing - how can my app be opened again after I've sent them to the browser for the user login?
Read this:
http://www.quora.com/OAuth-2-0/How-does-OAuth-2-0-work
or an even simpler but quick explanation:
http://agileanswer.blogspot.se/2012/08/oauth-20-for-my-ninth-grader.html
The redirect URI is the callback entry point of the app. Think about how OAuth for Facebook works - after end user accepts permissions, "something" has to be called by Facebook to get back to the app, and that "something" is the redirect URI. Furthermore, the redirect URI should be different than the initial entry point of the app.
The other key point to this puzzle is that you could launch your app from a URL given to a webview. To do this, i simply followed the guide on here:
http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
and
http://inchoo.net/mobile-development/iphone-development/launching-application-via-url-scheme/
note: on those last 2 links, "http://" works in opening mobile safari but "tel://" doesn't work in simulator
in the first app, I call
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"secondApp://"]];
In my second app, I register "secondApp" (and NOT "secondApp://") as the name of URL Scheme, with my company as the URL identifier.
Take a look at OAuth 2.0 playground.You will get an overview of the protocol.It is basically an environment(like any app) that shows you the steps involved in the protocol.
https://developers.google.com/oauthplayground/
redirected uri is the location where the user will be redirected after successfully login to your app. for example to get access token for your app in facebook you need to subimt redirected uri which is nothing only the app Domain that your provide when you create your facebook app.
If you are using Facebook SDK, you don't need to bother yourself to enter
anything for redirect URI on the app management page of facebook. Just setup a
URL scheme for your iOS app.
The URL scheme of your app should be a value "fbxxxxxxxxxxx" where xxxxxxxxxxx is
your app id as identified on facebook.
To setup URL scheme for your iOS app, go to info tab of your app settings
and add URL Type.

Resources