Google 400 Error: invalid request Custom scheme UR

2019-01-18 08:51发布

When I am signing into Gmail in my iOS App, I am getting the below error (screenshot) and the sign-in fields do not appear. We are loading the sign-in screen in a WKWebView.

  • We are using a custom URI redirect but why is google throwing this error now. What are the alternatives to a custom URI?
  • Swift 2.3 project
  • Using OAuthSwift v0.6.0 cocoapod
  • This started quite recently only in the past week or so I believe something changed with Google's APIs.

I have read that google is deprecating webviews for OAuth and will block requests on April 20, 2017. As seen here in a Google Developers Blog: https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html

Does this mean I already need to use or is there another viable solution? I thought I had more time before needing to update this.

enter image description here

11条回答
欢心
2楼-- · 2019-01-18 09:46

It creates two client ID. one for web and one for iOS application. Web client will be in the google plist by default. So it gives the above error. Use iOS Client id from google console or create credential for iOS application.

查看更多
够拽才男人
3楼-- · 2019-01-18 09:49

For my experience, I had followed Google's SignIn iOS Swift guide and had downloaded a Web OAuth JSON file. They literally provide you the wrong Plist file for an iOS setup.

Just in case somebody else runs into this issue here are the steps I followed:

  1. Go to the Google Developers console.
  2. Go to the Credentials section.
  3. Notice there are two items in the "OAuth 2.0 client IDs" section. (If you previously attempted to configure an iOS Google SignIn project.
  4. Click on the name of the "iOS client for ".
  5. Click "Download PLIST File".
  6. Delete the Google web Plist file from your project.
  7. Drop in the new iOS based Plist file.
  8. Copy over the new REVERSED_CLIENT_ID into your URL Types of the Info page of your project. (This is detailed in Google's guide).
  9. Attempt to run your app again.

Note: I got the Google Sign In API to work with Swift v3 and XCode v8.

查看更多
萌系小妹纸
4楼-- · 2019-01-18 09:49

I was getting the same error. Then I figured out, that I did not provide my app Bundle Id to access the Google Sign In Service in my app. You do that from the page with the link:

https://developers.google.com/mobile/add?platform=ios&cntapi=signin&cnturl=https:%2F%2Fdevelopers.google.com%2Fidentity%2Fsign-in%2Fios%2Fsign-in%3Fconfigured%3Dtrue&cntlbl=Continue%20Adding%20Sign-In

1.Sign in with your Google Developer account.

2.Create you app name and copy the App bundle Id from your project from: Project and Target List> General> Bundle Identifier.

3.Choose your Country

4.Enable Google- Sign In.

Then perform the necessary steps to integrate Google Sign In in with your iOS App.

查看更多
We Are One
5楼-- · 2019-01-18 09:50

Kindly check console.developers.google.com/apis/credentials for your project and see whether there is already a client_id in OAuth 2.0 client IDs section , if so then copy that client id and replace it with you GoogleService-Info.plist file's CLIENT_ID and accordingly change REVERSED_CLIENT_ID (in reverse manner) now clean and build your app and test it will work

查看更多
混吃等死
6楼-- · 2019-01-18 09:53

I was facing the same issue. I followed all the instructions to integrate my app several times, and played with the code to see if there was any hidden issue in the code. I downloaded and configured the sample app from google at github https://github.com/googlesamples/google-services and go the same issue, so it was not the code.

It seemed like there is something in my console configuration so I switched between different google console apps, and played changing the bundle IDs.

The only thing that managed to fix this issue was to use Firebase instead. I created an app in the firebase console, downloaded the new plist, and it worked.

Still not sure why this didn't work for me in the first place, this doesn't seem to be a common problem, but I hope this helps someone. cheers,

查看更多
登录 后发表回答