0

I am using ASWebAuthenticationSession to try and authenticate with Google's OAuth 2.0 API in a native Mac app. I registered my app in the Google Developer Console as a Desktop type app like this:

enter image description here

I construct my URL like this:

func createGmailURL() -> String{
  var url = String.init()

  url.append("https://accounts.google.com/o/oauth2/v2/auth")
  url.append("?client_id=*****.apps.googleusercontent.com")
  url.append("&redirect_uri=cova://oauth/gmail")
  url.append("&response_type=code")
  url.append("&scope=https://mail.google.com/")
    
  return url
}

I then initiate the request like this:

let url = createGmailURL()
    
guard let authURL = URL(string: url) else { return }
let scheme = "cova"
   
let session = ASWebAuthenticationSession(url: authURL, callbackURLScheme: scheme){ callbackURL, error in
  ...
}

Google seems to reject my request because of something related to the redirect_uri.

enter image description here

I can't for the life of me see what I've done wrong. It seems Google doesn't want to allow me to use a custom URI. Do I have to change the app type to something else? Does Desktop not apply to Mac apps?

Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128

0 Answers0