Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google OAuth 2.0 invalid_request, Missing Scheme

Tags:

ios

swift

oauth

I cannot authorize Google OAuth on ios, safari always say

400 That's an error.

Invalid parameter value for redirect_uri: Missing scheme: com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8

enter image description here I have checked API Key, Client_ID, client_secret on Google Console page many times and also create url scheme in the xcode.

Here are my Swift code:

oauthswift = OAuth2Swift( consumerKey: "xxxxx-3lmlrubo9345ng4qhtf62ud1i02m6ta8.apps.googleusercontent.com", consumerSecret: "xxxtg6qslUOC2np1sBg0hnWgBcpZb4", authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth", responseType: "token" ) let handle = oauthswift.authorize( withCallbackURL: URL(string: "com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8")!, scope: "profile", state:"GOOGLE", success: { credential, response, parameters in print(credential.oauthToken) // Do your request }, failure: { error in print(error.localizedDescription) } )

Could you help me ?

like image 820
haithngn Avatar asked Jun 15 '17 00:06

haithngn


2 Answers

It is pretty simple fix for this issue: just set prefix before your schema.

Example: your schema parameter:

com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8

the identifier of your iOS application:

net.the-red-queen.www

so, value for your redirect URI parameter is:

net.the-red-queen.www:com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8
like image 108
Vlad Avatar answered Oct 04 '22 02:10

Vlad


I think the actual issue is that you didn't specify a full URI. (The schema doesn't have a colon and then a path.) Try making your redirect_uri look something like the following (properly encoded, of course):

com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8:/oauth
like image 39
bfad Avatar answered Oct 04 '22 03:10

bfad