mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[GH-ISSUE #450] startAuthorizedRequest() fails to refresh the access token on Google Api #292
Labels
No labels
bug
cocoapod
duplicate
enhancement
feature-request
help wanted
help wanted
invalid
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/OAuthSwift#292
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mixable on GitHub (Apr 11, 2018).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/450
Description:
I use OAuth2Swift for authentication on Google. After updating from version 1.1.2 to version 1.2.0, requesting an access token is not possible anymore.
To call the Google api, I use startAuthorizedRequest() in the following way. In 1.1.2 this automatically handled the authorization:
The problem appears, when the current token expired and a new token is requested using the refresh token (inside the requestOAuthAccessToken() method). The error returned is:
It turned out, that this is a problem of the header I use. The send API (3) requires "Content-Type: application/json" to work, the access token API (2) does not allow this Content-Type. But the method requestOAuthAccessToken() uses the same header for both requests.
The reason for the same header is line 239 (OAuth2Swift.swift), which was changed from (v1.1.2):
to (v1.2.0):
The code seems to be correct, but I was wondering if anybody else has this problem. Or are there any suggestions, how to deal with this behavior?
OAuth Provider (Twitter, Github, ..):
Google, the API endpoints are:
(1) Authorize Url https://accounts.google.com/o/oauth2/auth?access_type=offline&prompt=consent
(2) Access Token Url: https://accounts.google.com/o/oauth2/token
(3) Send Email API: https://www.googleapis.com/gmail/v1/users/me/messages/send
OAuth Version:
OS (Please fill the version) :
Installation method:
Library version:
Xcode version:
9.0 (Swift 4.0)
9.0 (Swift 3.2)
8.x (Swift 3.x)
8.0 (Swift 2.3)
7.3.1
other: (Please fill in the version you are using.)
objective c
@phimage commented on GitHub (May 16, 2018):
I think that the fix for 1.2 reveal a real issue
why use request issue for authentication
there is this code in startAuthorizedRequest
@mixable maybe removing the header here will fix your issue
and if we want some specific header for renew, it must be another parameter
@mixable commented on GitHub (Jun 14, 2018):
@phimage yes, using a different parameter for the renew request should fix the problem
@phimage commented on GitHub (Jun 25, 2018):
I do want to change the behaviour if some people have provider that need some header so I add a new parameters called
renewHeadersSo @mixable you can do