Google-Login-Xamarin-Forms icon indicating copy to clipboard operation
Google-Login-Xamarin-Forms copied to clipboard

403 - disallowed_useragent

Open kolodiichyk opened this issue 8 years ago • 8 comments

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 avatar Dec 27 '16 17:12 kolodiichyk

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

kolodiichyk avatar Dec 27 '16 17:12 kolodiichyk

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 ?

krupanshu avatar Dec 30 '16 09:12 krupanshu

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);`

gsgou avatar Feb 08 '17 16:02 gsgou

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

jamesrcounts avatar Feb 13 '17 06:02 jamesrcounts

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

TamilRaja avatar Mar 17 '17 07:03 TamilRaja

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 PhoneGap and Ionic applications

ak47akshaykulkarni avatar Apr 17 '17 21:04 ak47akshaykulkarni

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

vishaalkathiriya avatar Apr 18 '17 12:04 vishaalkathiriya

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])

GotiMehta avatar May 10 '17 06:05 GotiMehta