[GH-ISSUE #247] How to do Google+/Youtube authentication correctly? #140

Closed
opened 2026-03-03 16:46:02 +03:00 by kerem · 3 comments
Owner

Originally created by @martinpilch on GitHub (Jun 30, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/247

Hello,
I'm trying to sign-in into Youtube and Google+ API using SafariURLHandler. Anytime I pass through the process and press Allow Safari tells me it can't open the page because address is invalid

In your dem I noticed you are using https://oauthswift.herokuapp.com/callback/google as Callback URL for GoogleDrive. I guess it's doing kind of redirect. How exactly does it work?
Thanks,
Martin

Originally created by @martinpilch on GitHub (Jun 30, 2016). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/247 Hello, I'm trying to sign-in into Youtube and Google+ API using `SafariURLHandler`. Anytime I pass through the process and press _Allow_ Safari tells me it can't open the page because address is invalid In your dem I noticed you are using `https://oauthswift.herokuapp.com/callback/google` as Callback URL for GoogleDrive. I guess it's doing kind of redirect. How exactly does it work? Thanks, Martin
kerem closed this issue 2026-03-03 16:46:03 +03:00
Author
Owner

@phimage commented on GitHub (Jun 30, 2016):

Yes it's redirect the url to a new one with scheme oauthswift://. (Custom scheme allow to pass information to the application, query of the url)

Herokuapp is used because Google accept only http:// url scheme.
Check also that your callback url must be declared or not in your Google account.

<!-- gh-comment-id:229676465 --> @phimage commented on GitHub (Jun 30, 2016): Yes it's redirect the url to a new one with scheme oauthswift://. (Custom scheme allow to pass information to the application, query of the url) Herokuapp is used because Google accept only http:// url scheme. Check also that your callback url must be declared or not in your Google account.
Author
Owner

@martinpilch commented on GitHub (Jun 30, 2016):

That's weird. Because my URL scheme I can see in Google Console is:
com.googleusercontent.apps.XXXXXXXXXXXXXXXXXXX
How is that possible? Are you able to authorise against G+ or Youtube?

<!-- gh-comment-id:229678364 --> @martinpilch commented on GitHub (Jun 30, 2016): That's weird. Because my URL scheme I can see in Google Console is: `com.googleusercontent.apps.XXXXXXXXXXXXXXXXXXX` How is that possible? Are you able to authorise against G+ or Youtube?
Author
Owner

@martinpilch commented on GitHub (Jun 30, 2016):

So I found solution. It's necessary to:

  • add this URL scheme: com.googleusercontent.apps.XXXXXXXXXXXXXXXXXXX into Supported URL schemes
  • also into LSApplicationQueriesSchemes section in plist.
  • and finally check for it also when handling URLs in AppDelegate (to pass it to OAuthSwift)

Then it's not necessary to do any redirect

This post helped me out: http://stackoverflow.com/questions/31506865/google-sign-in-crashes-on-ios-9-attempting-to-call-canopenurl

<!-- gh-comment-id:229689956 --> @martinpilch commented on GitHub (Jun 30, 2016): So I found solution. It's necessary to: - add this URL scheme: `com.googleusercontent.apps.XXXXXXXXXXXXXXXXXXX` into Supported URL schemes - also into `LSApplicationQueriesSchemes` section in plist. - and finally check for it also when handling URLs in AppDelegate (to pass it to OAuthSwift) Then it's not necessary to do any redirect This post helped me out: http://stackoverflow.com/questions/31506865/google-sign-in-crashes-on-ios-9-attempting-to-call-canopenurl
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#140
No description provided.