Instagram Auth Broken? - api

We just noticed that our app which relies on Instagram as the primary login is no longer working. In investigating this further, it appears the callback URL for Instagram stopped working. Now whenever anyone logs in via Instagram or signs up via Instagram, they are taken to the Instagram app instead of being asked to authenticate or taken into our app experience.
I checked another app that I know if, called "Print Studio" and the same thing is happening to them.
Is this issue happening to anyone else? Any clue as to what is causing it and has anyone heard from Instagram on a possible fix?

Yes. seems to effect all applications (at least the apps that are using the approved 3rd party API). I saw this issue few days ago and it got resolved by itself. I assume Instagram engineers are rolling some updates and broke something.
I suggest reporting an issue from the developer portal. https://www.instagram.com/developer/clients/manage/. as many reports as they receive, the better.
UPDATE:
The issue seems to be related to cookies / session persistent changes made on Instagram side.
To workaround the issue, redirect the user to the original auth url when you detect the user got to the Instagram homepage. Because the user is already logged in, this should pass the user to the correct redirect url without logging in again.
for example, in swift:
// MARK: - WKNavigationDelegate
override func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: #escaping (WKNavigationActionPolicy) -> Void) {
if let urlString = navigationAction.request.url?.absoluteString {
if urlString == "https://instagram.com" || urlString == "https://instagram.com/" ||
urlString == "https://www.instagram.com" || urlString == "https://www.instagram.com/" ||
urlString == "http://instagram.com" || urlString == "http://instagram.com/" ||
urlString == "http://www.instagram.com" || urlString == "http://www.instagram.com/" {
decisionHandler(.cancel)
self.refresh(nil) // reloads the original auth url
return
}
}
super.webView(webView, decidePolicyFor: navigationAction, decisionHandler: decisionHandler)
}

Related

Instagram Basic display Api (Not Able to get user Access token iOS Swift)

I want users of my iOS app to login via instagram.
As Instagram discontinued previous method, I am using Instagram Basic Display Api.
Is that okay to use this Api for authentication??
Secondly I have created an App on facebook developer site and setup instagram app and got instagram App ID.
Now How can I get user access token using this App ID??
https://api.instagram.com/oauth/authorize
?client_id={instagram-app-id}
&redirect_uri={redirect-uri}
&scope={scope}
&response_type=code
&state={state} //Optional
I am hitting this url with App ID and redirect uri in postman and in browser.It is not working and showing errors.
Try to load with webVieW
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "https://api.instagram.com/oauth/authorize?client_id=\(clientId)&redirect_uri=\(redirectUri)&scope=user_profile,user_media&response_type=code")
let urlRequest = URLRequest(url: url!)
webView.load(urlRequest)
}

OneDrive SDK UWA "AuthenticationFailure"

I'm building a W10 Universal app and I would like to know who is logged in to Windows so I can associate their data on my server with something that uniquely identifies the user w/o requiring a separate login.
OneDrive SDK is supposed to make this simple and easy.
So, I registered my app with OneDrive, used nuget to install the packages, downloaded the samples and wrote the following code.....
var scopes = new string[] { "wl.signin", "wl.offline_access", "onedrive.readonly" };
var client = OneDriveClientExtensions.GetUniversalClient(scopes);
try {
await client.AuthenticateAsync();
}
catch {
blahlblahblah;
}
This doesn't throw an exception, but, after AuthenticateAsync executes, the client's IsAuthenticated property is still false and the ServiceInfo's UserId is null.
So, I tried this next:
var client = OneDriveClient.GetMicrosoftAccountClient(
this.Resources["AppID"].ToString(),
this.Resources["ReturnUri"].ToString(),
scopes
);
where the AppID and ReturnUri match the Client ID and Redirect URL that are registered with the app.
This actually throws a OneDrive.Sdk.Error with a message of "Failed to retrieve a valid authentication token for the user."
So, I don't know what I'm doing wrong here. I'm at a total loss. I pulled up Fiddler to see what was being sent back & forth and nothing shows up. There's just not enough information for me to figure this out.
Anyone got any ideas?
So, ginach's workaround for the problem seems to be the solution until the bug is fixed. So, to sum it up....
Don't use the IsAuthenticated property of the UniversalClient. Instead, check the client's AuthenticationProvider's CurrentAccountSession to see if it has a value and an AccessToken.
var client = OneDriveClientExtensions.GetUniversalClient(scopes);
await client.AuthenticateAsync();
if (client.AuthenticationProvider.CurrentAccountSession != null && client.AuthenticationProvider.CurrentAccountSession.AccessToken != null) {
blahblahblahblahblah
}
This seems to do the trick.

How to display Salesforce login screen on my existing iOS native application?

I need to integrate Salesforce iOS native library in my iOS native application and I have to show salesforce login screen and flow as mentioned below:
I have a HOME screen in my iOS native application.
From there I have to navigate to Salesforce login screen.
User will enter credentials and Salesforce will validate it.
Once logged in success then it will back to my HOME screen with token/sessionID.
That token/sessionID I will use internally in my application.
To achieve this I have integrated "SalesforceMobileSDK-iOS-Distribution" from below link
https://github.com/forcedotcom/SalesforceMobileSDK-iOS-Distribution
in my application. But exactly I don't know from where to and how to start? which class will give me login screen of Salesforce. I tried something like
[SFUserAccountManager sharedInstance].oauthClientId = strClientID;
[SFUserAccountManager sharedInstance].oauthCompletionUrl = strCallbackURI;
[SFUserAccountManager sharedInstance].scopes = [NSSet setWithObjects:#"api",#"web", nil];
and
[SalesforceSDKManager sharedManager].connectedAppId = strClientID;
[SalesforceSDKManager sharedManager].connectedAppCallbackUri = strCallbackURI;
[SalesforceSDKManager sharedManager].authScopes = #[#"web", #"api"];
[[SalesforceSDKManager sharedManager] launch];
I have connected app information such as Client ID, Secret code and Redirect URI. How can I proceed?
If I use zkSforce library from this link https://github.com/superfell/zkSforce
Does it achieve my requirement?
Please help me. Thanks in advance.
Finally I achieved it and the good answer for this question is
Download "SalesforceMobileSDK-iOS-Distribution" from below link https://github.com/forcedotcom/SalesforceMobileSDK-iOS-Distribution .
Extract all the "-Release.zip" files and add those to your application.
Set Header Search path for all libraries as "$(SRCROOT)/your app name/your library name" and choose "recursive".
Set Other linker flags such as "-ObjC" and "-all_load".
Import "SFUserAccountManager.h", "SFAuthenticationManager.h" and "SFIdentityData.h" files.
Add below code snippet to your login action
[SFUserAccountManager sharedInstance].oauthClientId = strClientID;
[SFUserAccountManager sharedInstance].oauthCompletionUrl = strCallbackURI;
// [SFUserAccountManager sharedInstance].scopes = [NSSet setWithObjects:#"web", #"api", nil];
[[SFAuthenticationManager sharedManager] addDelegate:self];
[[SFAuthenticationManager sharedManager]
loginWithCompletion:(SFOAuthFlowSuccessCallbackBlock)^(SFOAuthInfo *info) {
NSLog(#"Authentication Done");
SFIdentityData *claims = [SFAuthenticationManager sharedManager].idCoordinator.idData;
NSLog(#"claims = %#",claims);
NSLog(#"accessToken = %#", [SFAuthenticationManager sharedManager].coordinator.credentials.accessToken);
}
failure:(SFOAuthFlowFailureCallbackBlock)^(SFOAuthInfo *info, NSError *error) {
NSLog(#"Authentication Failed");
// handle error hare.
}
];
#pragma mark - SFAuthenticationManager
- (void)authManager:(SFAuthenticationManager *)manager willDisplayAuthWebView:(UIWebView *)view{
}
- (void)authManagerDidFail:(SFAuthenticationManager *)manager error:(NSError*)error info:(SFOAuthInfo *)info{
}
hope it would helpful to you.
Note: According to me the "Call back URI" should not start with either "http" or "https".
Sales force uses oAuth login. The code should do the magic.
What is your main problem ? were u not able show the login page after running the above code ?
Other way to check how SFDC iOS SDK works is to install forceios npm package & create a native iOS application from the cmd it provides. [https://www.npmjs.com/package/forceios]
Application created gives you an glimpse on how the SFDC SDK works [login, Fetch Data from SFDC etc.]
1) integrate using CocoaPods
pod 'SalesforceSDKCore'
import <SFAuthenticationManager.h>
2) make sure you properly configure the OAuthRedirect URL
yourapp://authdone
add this redirect URL in salesforce server config
config redirect URL in your Info.plist
3) use Ganesh's code above, employing SFAuthenticationManager with the oauthCompletionUrl set to the OAuthRedirect URL you have configured. The callback will have the entire user object on success.

Log the logins to the various applications that identityserver manages

We've got a lot of sites with common authentication by thinktecture identityserver v2.
Now we would like to have a log of the logins to the sites. We've got a custom IUserRepository where we could log a user login in, but how would we goahead and grab the site a user is loggin into?
And when we jump from one site to another - how could that be logged
In case there's no built in support for this, where is the best place to modify the code?
It seems like it could be done in the WSFederationController and in the Issue method I could get the realm based on the uri.
public ActionResult Issue()
{
Tracing.Start("WS-Federation endpoint.");
if (!ConfigurationRepository.WSFederation.Enabled && ConfigurationRepository.WSFederation.EnableAuthentication)
{
return new HttpNotFoundResult();
}
var message = WSFederationMessage.CreateFromUri(HttpContext.Request.Url);
// sign in
var signinMessage = message as SignInRequestMessage;
if (signinMessage != null)
{
// Is this a good place to log current user and the application the user is loggin into to db???
// or does Thinktecture have some build in functionaltiy for this?
return ProcessWSFederationSignIn(signinMessage, ClaimsPrincipal.Current);
}
Larsi

Facebook C# SDK: OAuth 2 in Silverlight 4 browser app

I'm completely newbie at authentication proccess with OAuth (I'm trying to make use of OAuth 2, exactly), and the example I am following to authenticate by using Facebook SDK latest release says that this code snippet should work for C# .NET environments (http://blog.prabir.me/post/Facebook-CSharp-SDK-Writing-your-first-Facebook-Application.aspx):
webBrowser.Navigate(loginUrl);
private void webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
FacebookOAuthResult result;
if (FacebookOAuthResult.TryParse(e.Url, out result))
{
if (result.IsSuccess)
{
var accesstoken = result.AccessToken;
}
else
{
var errorDescription = result.ErrorDescription;
var errorReason = result.ErrorReason;
}
}
}
Since I am programming a browser SL app, the WebBrowser control displays nothing, so I am not either able to catch the response, how could I do something equivalent to that in my app? Or how could I manage to complete the authentication proccess if there is no equivalent way? Thanks!
A suggestion: Why don't you try to parse the WebResponse when you receive it as opposed to listening for the event?
I use Facebook OAuth in my web app. It is nothing but a series of URL posts with the correct parameters.
Take a look at this post: Login using Facebook Problem after logging out (All the details are in the answer and comments)
Here are the brief steps:
Call the Facebook OAuth Dialog URL with your AppId, redirect url, and permissions. Request_type should be "code"
When the user logs in and authorizes you application, they will be redirected to the redirect url with a "code" querystring parameter.
Take the value of the code parameter and make another call to Facebook to get the token.
Use this token to make calls on the user's behalf.