HoussemDellai / Google-Login-Xamarin-Forms

Login with Google API from Xamarin.Android app
23 stars 18 forks source link

403 - disallowed_useragent #1

Open kolodiichyk opened 7 years ago

kolodiichyk commented 7 years ago

After google policy update - iOS example not works - error 403 - disallowed_useragent

"This user-agent is not permitted to make an OAuth authorization request to Google as it is classified as an embedded user-agent (also known as a web-view). Per our policy, only browser are permitted to make authorization requests to Google. We offer several libraries and samples for native apps to perform authorization request in the browser."

kolodiichyk commented 7 years ago

p.s. Error is thrown after set new ClientId (generated in console.developers.google.com)

krupanshu commented 7 years ago

I face the same issue as @koland face, If I am trying to create new clientId and try to use it then it shows "disallowed_useragent".

Also as I run the sample project, It open the URL in web view, but also there it shows a warning like below

"Notice for developers : authorization requests in embedded browsers will be blocked on April 20, 2017"

From above this, do we need to open the URL in SAFARI for OAuth Validation now on ?

gsgou commented 7 years ago

Put the following code into FinishedLaunching on your AppDelegate.cs (before global::Xamarin.Forms.Forms.Init()):

`// define useragent android like string userAgent = "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Mobile Safari/537.36";

// set default useragent NSDictionary dictionary = NSDictionary.FromObjectAndKey(NSObject.FromObject(userAgent), NSObject.FromObject("UserAgent")); NSUserDefaults.StandardUserDefaults.RegisterDefaults(dictionary);`

jamesrcounts commented 7 years ago

We tried @sgou solution and we are still getting a 403 error.

TamilRaja commented 7 years ago

Anybody fix this issues. Kindly share with me... i have face same like this issues in google calendar used in swift (IOS)

ak47akshaykulkarni commented 7 years ago

After wasting couple of hours in implementing and coming across this error with a new project I created in google console and using that client_id, I checked with one of my older project's client_id and it worked. So as @koland said I agree that smart google has noticed this behavior and stopping the support to get access token from WebView at least stopped for the new client_ids generated and still working with the old ones may be giving developers time to migrate. Now I want to see the same application after 20th April. and need to verify @sgou 's solution for iOS I am more concerned about is PhoneGapand Ionicapplications

vishaalkathiriya commented 7 years ago

I am also facing same issue with Google login. Please share solution if anybody have already.

GotiMehta commented 7 years ago

I recently faced the issue. I tried @sgou 's solution but it did not work though I got the reference 👍 . And following code resolved the issue: in AppDelegate;

// Register browser to avoid '403 Error: disallowed_useragent' error in Google sign in       
let dict = NSDictionary(object: "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", forKey: "UserAgent" as NSCopying)      
UserDefaults.standard.register(defaults: dict as! [String : Any])