Call a custom URL scheme (myapp://) from a Firebase Cloud Function - ios

I'm trying to make it possible to log into an iOS app with Instagram.
I'm trying to do that with SFAuthenticationSession and unfortunately SFAuthenticationSession requires the callbackURL to be a custom one (like myapp://) and Instagram only allows http/https links as redirect URIs.
The solution I've come up with is to provide Instagram with a URL of a Firebase Cloud Function and do a redirect or another request in my cloud function to myapp://something.
The request module only makes http/https requests and I haven't found a way to simply call my custom URL.
As far as I have observed the SFAuthenticationSession's callback closure will only be called if the user cancels or if the thing detects a call to the provided callbackURLScheme.
Can you guys help me out? Thank you.

Related

Azure Mobile Apps - Request user profile information

How do you make a request to Google to get a user's profile information with the returned tokens from Azure Mobile Apps? Specifically I am using the iOS Microsoft SDK in Objective-C.
I found this article but it looks to be referencing old information based on the date and the response that was returned.
I also tried calling /.auth/me as a GET request, but that returned Cannot GET /api/.auth/me
You need to make an HTTP request to /.auth/me, but without using the custom API support that's in the iOS SDK. In other words, use NSURLRequest directly, and not MSClient.invokeAPI. Your call needs to be authenticated, so put the token from client.currentUser.mobileServiceAuthenticationToken in the X-ZUMO-AUTH header.
We have an open feature request to add a method to the client SDKs to make this easier: https://github.com/Azure/azure-mobile-apps/issues/30.
And, you're right that your article was referencing information on Azure Mobile Services, which behaves completely differently when it comes to authentication.

How to login to a website with java script using swift?

I want to login to a website and get the page source code from the website.
The page I want to login is "http://sas.ksa.hs.kr/scmanager/stuweb/index.jsp" and the page I want to get the source code after the login is "http://students.ksa.hs.kr/scmanager/stuweb/sukang/spare.jsp"
I'm very new in developing iOS apps. I couldn't understand any questions about this topic in stackoverflow.
Please help.
Just use any of traffice analyzers (highly recommended Telerik Fiddler), enabled it during the login process and you'll see all the requests send by your browser. You should reproduce them in your application by constructing the same requests bodies and send them to the same URLs - it's like a browser without displaying any content. Read more about HTTP protocol and you'll have success!
For HTTP in swift you can use NSURLSession or any libraries like Alamofire

CallBack url for social authemtication using ngCordovaOauth

If i am using ngCordovaOauth for authentication for Facebook,Twitter and Instagram
then what should be callback url, when developing and app for mobile .
If you read the plugin docs
Using ngCordovaOauth In Your Project
Each web service API acts independently in this library. However, when
configuring each web service, one thing must remain consistent. You
must use http://localhost/callback as your callback / redirect URI.
This is because this library will perform tasks when this URL is
found.
So, the callback url is http://localhost/callback

Pass cookie to UIWebView - iOS

I have an iOS application which allows the user to use Apple's built in Accounts/Social frameworks to login via Facebook.
One question I have is, is there a way to pass user auth cookie from ACAccountStore to a UIWebView?
This will mean that, if a user clicks on a link and the built in web view page is shown, they will be able to comment/like/etc without having to login in the web view too.
Thanks,
Dan
I think it won't be possible if you don't control the service you want to be authenticated with in said webviews.
Injecting arbitrary cookies into a UIWebView is possible, as described e.g. here: Is it possible to set a cookie manually using sharedHTTPCookieStorage for a UIWebView?.
Cached auth tokens can be retrieved from ACAccountCredential. But OAuth tokens are not session-authenticating cookies.
Facebook does that. Whenever a webview is opened in their iOS client, the user will be automatically authenticated with Facebook in that webview. But they have control over their own service, so they created a mechanism for their iOS client to request session-authenticating cookies (that they then inject into webviews).
In general, though, being a 3rd party developer, you won't be able to reproduce that behavior. Unless of course given service has such mechanism for their own needs and you do some reverse-engineering.

How to consume functionalities of a website that requires a Facebook authentication?

I have a website that requires any user to be logged in using the Facebook auth system.
On the other hand I am making an iOS App that needs to consume functionalities of the website. I implemented the SSO system on the iOS system but I don't get how I'm supposed to call my webservices in a way that tells the backend that "it's ok, I'm authenticated on the iOS app".
Is there anything to do with the signed_request parameters on the iOS side? If yes, I didn't find anyway yet to get that parameter.
Do you have any clue to help me deal with my issue?
Thanks
https://developers.facebook.com/docs/authentication/signed_request/
The signed_request parameter is utilized to share information between Facebook and app in a number of different scenarios:
A signed_request is passed to Apps on Facebook.com when they are loaded into the Facebook environment
A signed_request is passed to any app that has registered an Deauthorized Callback in the Developer App whenever a given user removes the app using the App Dashboard
A signed_request is passed to apps that use the Registration Plugin whenever a user successfully registers with their app
Does iOS use any of these?
** EDIT **
Ok thanks, can you edit your answer and add the fact that I can't
access the signed_request parameter? – MartinMoizard
From Martin: iOS cannot access the signed request parameter probably because iOS is not a webserver that is able to accept HTTP Post paramteres.
I am struggling with this same problem, and it seems that OAuth is actually an authorization protocol, not an authentication protocol. See:
http://www.thread-safe.com/2012/01/problem-with-oauth-for-authentication.html
Seems like the signed request would solve this problem nicely. Not sure why we cannot get them on iOS. Best I can figure out is I need to pass my access_token from the iOS client to my server, and then it can ask graph.facebook.com what user it represents.

Resources