[GH-ISSUE #434] configuring OAuth2 bearer authentication #282

Closed
opened 2026-03-03 16:47:21 +03:00 by kerem · 5 comments
Owner

Originally created by @MunaTayeb on GitHub (Feb 8, 2018).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/434

Description:

I'm required to use OAuth2 bearer authentication, which is when the user login successfuly, I got an access token and refresh token from the server. once the access token expires (code 401), I use the refresh token on some endpoint to get the new access and refresh tokens, I couldn't find any guide regarding this, is it possible using this library? if yes, how to make the refreshing process automatic?

OAuth Provider (Twitter, Github, ..):

Bearer authentication

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

  • iOS :
  • OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • Manually

Library version:

  • head
  • v1.2 (Swift 4.0)
  • v1.0.0
  • v0.6
  • other: (Please fill in the version you are using.)

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
Originally created by @MunaTayeb on GitHub (Feb 8, 2018). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/434 ### Description: I'm required to use OAuth2 bearer authentication, which is when the user login successfuly, I got an access token and refresh token from the server. once the access token expires (code 401), I use the refresh token on some endpoint to get the new access and refresh tokens, I couldn't find any guide regarding this, is it possible using this library? if yes, how to make the refreshing process automatic? ### OAuth Provider (Twitter, Github, ..): Bearer authentication ### OAuth Version: - [ ] Version 1 - [X] Version 2 ### OS (Please fill the version) : - [X] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [ ] CocoaPods - [X] Manually ### Library version: - [X] head - [ ] v1.2 (Swift 4.0) - [ ] v1.0.0 - [ ] v0.6 - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [ ] 9.0 (Swift 4.0) - [X] 9.0 (Swift 3.2) - [ ] 8.x (Swift 3.x) - [ ] 8.0 (Swift 2.3) - [ ] 7.3.1
kerem closed this issue 2026-03-03 16:47:21 +03:00
Author
Owner
<!-- gh-comment-id:364061045 --> @phimage commented on GitHub (Feb 8, 2018): https://github.com/OAuthSwift/OAuthSwift/wiki/OAuth-2.0-Token-Expiration
Author
Owner

@MunaTayeb commented on GitHub (Feb 8, 2018):

I have acess token, refresh token and one endpoint which recives the refresh and send back new ones.
where should I add these three when creating an OAuth2Swift object and setting it's parameters?

<!-- gh-comment-id:364072944 --> @MunaTayeb commented on GitHub (Feb 8, 2018): I have acess token, refresh token and one endpoint which recives the refresh and send back new ones. where should I add these three when creating an OAuth2Swift object and setting it's parameters?
Author
Owner

@phimage commented on GitHub (Feb 8, 2018):

no where, there is no standard

see startAuthorizedRequest signature, you have a callback to make the request your self

or see OAuthSwiftAlamofire project with request retrier

<!-- gh-comment-id:364075143 --> @phimage commented on GitHub (Feb 8, 2018): no where, there is no standard see startAuthorizedRequest signature, you have a callback to make the request your self or see OAuthSwiftAlamofire project with request retrier
Author
Owner

@MunaTayeb commented on GitHub (Feb 11, 2018):

Ok I figure it out after reading the Wiki.. Thank you

is there a way to get the error status code? ex: 400,500 ...

<!-- gh-comment-id:364727470 --> @MunaTayeb commented on GitHub (Feb 11, 2018): Ok I figure it out after reading the Wiki.. Thank you is there a way to get the error status code? ex: 400,500 ...
Author
Owner

@phimage commented on GitHub (Feb 11, 2018):

if requestError, you can take the underlying error as NSError or URLError
an example with NSError
https://github.com/OAuthSwift/OAuthSwift/blob/master/Sources/NSError%2BOAuthSwift.swift

<!-- gh-comment-id:364776864 --> @phimage commented on GitHub (Feb 11, 2018): if requestError, you can take the underlying error as NSError or URLError an example with NSError https://github.com/OAuthSwift/OAuthSwift/blob/master/Sources/NSError%2BOAuthSwift.swift
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#282
No description provided.