Always getting error "OAuth2: No authorization context present" while using OAuth2 library in swift - ios

I am using OAuth2 for integrating Outlook Calendar APIs with my iOS app.I was following with this tutorial: Adding Calendar and Contacts APIs.
After the login UI, the presenting controller dismisses. Following that, while trying to implement any APIs (Calendar, Mail, etc), it shows this error:
OAuth2: No authorization context present
Anyone please help! I have been sitting for hours.

Look at this pull request: https://github.com/jasonjoh/swift-tutorial/pull/8
There was a change (either in XCode or p2.oauth2) since that tutorial was written. You need to use a different signature for your app delegate.

Related

Custom scheme URIs are not allowed for 'Web' client type - Google with Firebase

I am trying to implement google sign in using firebase in to my iOS app. I follow this tutorial.
https://firebase.google.com/docs/auth/ios/google-signin
I have setup the iOS app in firebase and use the google clientID and reversedClientID from the dowloaded GoogleService-Info.plist.
FYI: I have a custom sign-in button instead of the google sign in button. Anyway when i click the sign in button, google following error display in a webview.
I know my problem is the same as which described in this question.
Google 400 Error: invalid request Custom scheme URIs are not allowed for 'Web' client type
But, in my case, I have created the app in Firebase still I get the error. Any idea please...
The first step is to check if you have already the OAuth 2.0 ID for iOS. To do this please open the Credentials page in the API Console. I hope you will find iOS client for your application under OAuth 2.0 client IDs section. If not, please follow this Guide
The second step is to replace the Web Client ID with in iOS Client ID from OAuth 2.0 client IDs section. To do this, you should open the GoogleService-Info.plist and modify following keys: CLIENT_ID with [value].apps.googleusercontent.com and REVERSED_CLIENT_ID with com.googleusercontent.apps.[value].
if you're using flutterfire ui package you need to change the client id parameter in your GoogleProviderConfiguration class with the iOS client id,
you can copy it from here Credential page
example:
providerConfigs: [
GoogleProviderConfiguration(
clientId: "your copied key here"),
]
re-build you're app and you should be good to go
I've just faced this same issue using flutterfire_ui on Flutter.
The error appears to be from a couple of things. As Valeriy points out you need the ios client ID. But I still got the error if I used the scopes
openid
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
Instead change these to
openid
email
profile
Strangely the opposite is true for Android, where the WebID and the first of the scopes should be used.
It also pays to be aware of the OAuth Content Screen..
In google cloud go to APIs & Services > OAuth consent screen > Edit.
You can add scopes here and fix any missing required fields that Firebase might not be filling out (I had 1). I believe this takes a while to propagate after a change, so give it an hour.

Do I need to update my Google Drive sign in?

I have an iOS app that logs in to a Google Drive using the method outlined in the Google Quickstart page - iOS Quickstart
I have seen the message from Google about modernizing OAuth interactions
Authorisation requests in embedded browsers will be blocked on April 20 2017
I'm not using an embedded browser but I'm still getting this warning message. Can anyone confirm if this is a general message displayed for everyone, or does the fact that you're seeing the message indicate that it is relevant?
Do I need to change my access, and what happens if I keep trying to use this legacy method - does it simply fail?
I think that iOS Quickstart is outdated as far as the login part goes and that you'll need to use the new Google Sign-In procedure.
Google Sign-In for iOS:
https://developers.google.com/identity/sign-in/ios/start
This page had some useful info when learning about the process:
https://www.appcoda.com/google-sign-in-how-to/
A few other things I found useful for me:
1) .hasAuthInKeychain can be used to determine if a "silent" login should work
2) .currentUser of nil means you need to login through code, but user doesn't necessarily need to see login screen (if keychain auth exists)
3) After getting a .currentUser, you can use the old API code (at least for me) by assigning the authorizer as follows:
service.authorizer = [GIDSignIn sharedInstance].currentUser.authentication.fetcherAuthorizer;
Edit:
I've decided to switch to AppAuth instead of "Sign In". I'm using the following cocoapods which use the latest (I think, v3) Google API, along with AppAuth
pod 'GoogleAPIClientForREST'
pod 'GoogleAPIClientForREST/Drive'
pod 'GTMAppAuth'

ios flickr api: Flickr callback URL not being called

I'm attempting to hook my application into Flickr but having issues during the Authentication process.
I've followed instructions in:
https://github.com/devedup/FlickrKit
I've created a CFBundleURLTypes for my application (let's call it myapp://) and tested that it works (i.e. I type myapp:// in a safari). I've successfully called the authentication URL in Flickr, it shows the login, asks the user to grant my app the necessary permissions then instead of redirecting back to my app via my URL...it does nothing, and the app is not authenticated.
I used FlickrKit demo app replacing its api key/secret/CFbundleUrltypes with mines and the issue is the same, so the problem is not in the code but rather in the way i registered my app in flickr. Said that...I just followed the instructions in Flickr "Edit Authentication Flow" so I guess the issue is with the callback url I put in flickr. I used myapp://auth? as described in many posts in the internet but does not authenticate or call back my app.
This is not the same issue reported here:
Flickr Authentication Flow and iPhone
but rather similar to the unanswered post:
flickr callback URL not working
The Info.plist for the custom URL handler and the AppDelegate code are a copy&paste from the flickrKit demo app [no need to reinvent the wheel] and anyway even after changing api key secret and url in flickrKit demo app with mines...the app is not called back, so it must be something wrong in my app registration.
Anybody experienced a similar behavior ? i ruled out objective-c code and callback url as the issue, so what is left is the flickr part but not sure where to look for help... so i wrote this post.
Thanks for any tip,
dom
Probably this is a problem of api signature calculation. All the parameters passed via method should be used to calculate an api signature.

Invalid redirect_uri when attempting to use social sign in with Gigya with iOS

I'm attempting to integrate Gigya's social login into an iOS application. Within a ViewController, I'm triggering the showLoginUI method on the GSAPI class. This appears to work fine and invokes the web view containing links to each of the social providers. The problem that I'm facing is clicking on any of the providers, the delegate method gsLoginUIDidFail is returning the responseText
{"errorCode":400011,"errorMessage":"Invalid redirect_uri"}
I've been following the guide found at http://developers.gigya.com/035_Mobile_SDKs/010_iPhone
Initially, I thought that perhaps this was a problem with the gigya test providers, but adding a real provider app to the gigya configuration didn't resolve the problem.
The gigya api internally references a gsapi://login_result/ and wondered if perhaps this is the issue as I can't seem to work out where that protocol is being defined.
Also, running the test application linked in the guide encounters the same issue.
Hoping someone has encountered this problem themselves and knows what trick i'm missing to get things working?
Ok, so it turns out if you have already been using the API and have an API key, it's super easy to miss the step within "Gigya Setup - Obtain Your Gigya API Key" which requires you to tick a Enable Mobile or Desktop Client Applications API Access checkbox.
Ensuring this is set resolves the issue.

How to use yammer's oauth2 from iOS?

I'm trying to get a iOS client to make use of Yammer's Oauth2 to validate a user. I first tried the GTM-OAuth2 code, but I cannot get it to understand the response from Yammer. It appears that the GTM code is expecting the access_code as a query parameter, where as Yammer is returning it as a uri fragment. I hack he GTM code to see the fragment, but now it appears to be thinking that there is an error because the code and message fields are not in the response from Yammer.
I've also tried to use OAuth2Client api but the problem there is that Yammer does not seem to want to use the redirect_uri I pass to it, so Safari never gets the custom url and therefore never calls back to the app.
Does anyone have a working example of using Yammer's OAuth2?
I would also be interested if anyone has got GTM-OAuth2 to work with Facebook?
Yeah Yammer has a shitty implementation of oAuth. Looks like each service has taken its own implementation of oauth. anyway yammer requires the user to copy a 4-digit code from its website, go back to your service paste that code in your website. Only then you can request for access code.
check this - http://www.tutorialjinni.com/2011/04/yammer-api-example.html (its in php but hope you can get the gist).
Nothing you can do about it but a fun read - Yammer API sucks

Resources