The redirect to the app after the sign in through custom scheme works fine and I'm able to obtain the authorization code.
@IBAction func login() {
do {
try GAppAuth.shared.authorize(in: self) { auth in
if auth {
if GAppAuth.shared.isAuthorized() {
let authorization = GAppAuth.shared.getCurrentAuthorization()
sendAuthCodeToServer(serverAuthCode: authorization?.authState.lastAuthorizationResponse.authorizationCode, userName: authorization?.userEmail, userEmail: authorization?.userEmail)
}
}
}
} catch let error {
print(error.localizedDescription)
}
}
But when I share the authorization code with my server, I get an error on the request to exchange the authentication code to obtain access_token and refresh_token.
400 {'error': 'invalid_grant', 'error_description': 'Bad Request'}
Please note that that I'm able to exchange the authorization code with access_token and refesh_token on the device.
I suspect there's something that Google libraries for login do that is not implemented in GAppAuth (see openid/AppAuth-Android#293).