[GH-ISSUE #624] Garmin - Error copying matching creds #406

Closed
opened 2026-03-03 16:48:26 +03:00 by kerem · 1 comment
Owner

Originally created by @dutennakoon on GitHub (Sep 9, 2020).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/624

Description:

Whenever I need to authorise Garmin I'm getting this below error.

[TRACE] OAuthSwiftHTTPRequest.swift [229]: URLRequest is created: https://connectapi.garmin.com/oauth-service/oauth/request_token
2020-09-09 13:17:47.917935+0530 OAuthSwiftDemo[46731:977404] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    ptcl = htps;
    "r_Attributes" = 1;
    sdmn = "connect.garmin.com";
    srvr = "connectapi.garmin.com";
    sync = syna;
} 

2020-09-09 13:55:25.026140+0530 Fresh Fitness Food[47654:1001231] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    ptcl = htps;
    "r_Attributes" = 1;
    sdmn = "connect.garmin.com";
    srvr = "connectapi.garmin.com";
    sync = syna;
}
requestError[Error Domain=OAuthSwiftError Code=401 "HTTP Status 401: Unauthorized, Response: <!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Invalid nonce and timestamp</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Garmin Connect API Server</h3></body></html>" UserInfo={Response-Headers={
    "Content-Language" = en;
    "Content-Type" = "text/html;charset=utf-8";
    Date = "Wed, 09 Sep 2020 08:25:25 GMT";
    Server = cloudflare;
    "Set-Cookie" = "__cfduid=d7a2a68ad15d1143f4043a51d15ce98aa1599639925; expires=Fri, 09-Oct-20 08:25:25 GMT; path=/; domain=.connectapi.garmin.com; HttpOnly; SameSite=Lax";
    "Www-Authenticate" = "OAuth realm=\"connect.garmin.com\"";
    "alt-svc" = "h3-27=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-29=\":443\"; ma=86400";
    "cf-cache-status" = DYNAMIC;
    "cf-ray" = "5cff84bbd9ec1047-MRS";
    "cf-request-id" = 051391496b00001047da2bf200000001;
    "expect-ct" = "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"";
}, NSLocalizedDescription=HTTP Status 401: Unauthorized, Response: <!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Invalid nonce and timestamp</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Garmin Connect API Server</h3></body></html>, OAuthSwiftError.response=<NSHTTPURLResponse: 0x6000036087a0> { URL: https://connectapi.garmin.com/oauth-service/oauth/request_token } { Status Code: 401, Headers {
    "Content-Language" =     (
        en
    );
    "Content-Type" =     (
        "text/html;charset=utf-8"
    );
    Date =     (
        "Wed, 09 Sep 2020 08:25:25 GMT"
    );
    Server =     (
        cloudflare
    );
    "Set-Cookie" =     (
        "__cfduid=d7a2a68ad15d1143f4043a51d15ce98aa1599639925; expires=Fri, 09-Oct-20 08:25:25 GMT; path=/; domain=.connectapi.garmin.com; HttpOnly; SameSite=Lax"
    );
    "Www-Authenticate" =     (
        "OAuth realm=\"connect.garmin.com\""
    );
    "alt-svc" =     (
        "h3-27=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-29=\":443\"; ma=86400"
    );
    "cf-cache-status" =     (
        DYNAMIC
    );
    "cf-ray" =     (
        "5cff84bbd9ec1047-MRS"
    );
    "cf-request-id" =     (
        051391496b00001047da2bf200000001
    );
    "expect-ct" =     (
        "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
    );
} }, Response-Body=<!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Invalid nonce and timestamp</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Garmin Connect API Server</h3></body></html>, NSErrorFailingURLKey=https://connectapi.garmin.com/oauth-service/oauth/request_token, OAuthSwiftError.response.data={length = 1088, bytes = 0x3c21646f 63747970 65206874 6d6c3e3c ... 3e3c2f68 746d6c3e }}]

Code as follows...

self.oauthSwift = OAuth1Swift(
            consumerKey: HealthConfigurationService.getGarminConsumerKey(),
            consumerSecret: HealthConfigurationService.getGarminConsumerSecret(),
            requestTokenUrl: HealthConfigurationService.getGarminRequestTokenUrl(),
            authorizeUrl: HealthConfigurationService.getGarminAuthorizeUrl(),
            accessTokenUrl: HealthConfigurationService.getGarminAccessTokenUrl())
        
        self.oauthSwift.addCallbackURLToAuthorizeURL = true


            self.oauthSwift.authorizeURLHandler = SafariURLHandler(viewController: UIApplication.shared.topMostViewController()!, oauthSwift: self.oauthSwift)
            self.oauthSwift.authorize(
            withCallbackURL: HealthConfigurationService.getGarminCallbackURL()) { result in
                switch result {
                case .success:
                    print("success")
                case .failure(let error):
                    print(error.description)
                }
            }

OAuth Provider? (Twitter, Github, ..):

  • Garmin

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

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

Installation method:

  • Carthage
  • CocoaPods
  • Swift Package Manager
  • Manually

Library version:

  • head
  • v2.1.0
  • v2.0.0
  • v1.4.1
  • other: (Please fill in the version you are using.)

Xcode version:

  • 11.6 (Swift 5.2)

  • 11.4 (Swift 5.2)

  • 11.x (Swift 5.1)

  • 10.x (Swift 5.0)

  • other: (Please fill in the version you are using.)

  • objective c

Originally created by @dutennakoon on GitHub (Sep 9, 2020). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/624 ### Description: Whenever I need to authorise Garmin I'm getting this below error. ``` [TRACE] OAuthSwiftHTTPRequest.swift [229]: URLRequest is created: https://connectapi.garmin.com/oauth-service/oauth/request_token 2020-09-09 13:17:47.917935+0530 OAuthSwiftDemo[46731:977404] CredStore - performQuery - Error copying matching creds. Error=-25300, query={ class = inet; "m_Limit" = "m_LimitAll"; ptcl = htps; "r_Attributes" = 1; sdmn = "connect.garmin.com"; srvr = "connectapi.garmin.com"; sync = syna; } 2020-09-09 13:55:25.026140+0530 Fresh Fitness Food[47654:1001231] CredStore - performQuery - Error copying matching creds. Error=-25300, query={ class = inet; "m_Limit" = "m_LimitAll"; ptcl = htps; "r_Attributes" = 1; sdmn = "connect.garmin.com"; srvr = "connectapi.garmin.com"; sync = syna; } requestError[Error Domain=OAuthSwiftError Code=401 "HTTP Status 401: Unauthorized, Response: <!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Invalid nonce and timestamp</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Garmin Connect API Server</h3></body></html>" UserInfo={Response-Headers={ "Content-Language" = en; "Content-Type" = "text/html;charset=utf-8"; Date = "Wed, 09 Sep 2020 08:25:25 GMT"; Server = cloudflare; "Set-Cookie" = "__cfduid=d7a2a68ad15d1143f4043a51d15ce98aa1599639925; expires=Fri, 09-Oct-20 08:25:25 GMT; path=/; domain=.connectapi.garmin.com; HttpOnly; SameSite=Lax"; "Www-Authenticate" = "OAuth realm=\"connect.garmin.com\""; "alt-svc" = "h3-27=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-29=\":443\"; ma=86400"; "cf-cache-status" = DYNAMIC; "cf-ray" = "5cff84bbd9ec1047-MRS"; "cf-request-id" = 051391496b00001047da2bf200000001; "expect-ct" = "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""; }, NSLocalizedDescription=HTTP Status 401: Unauthorized, Response: <!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Invalid nonce and timestamp</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Garmin Connect API Server</h3></body></html>, OAuthSwiftError.response=<NSHTTPURLResponse: 0x6000036087a0> { URL: https://connectapi.garmin.com/oauth-service/oauth/request_token } { Status Code: 401, Headers { "Content-Language" = ( en ); "Content-Type" = ( "text/html;charset=utf-8" ); Date = ( "Wed, 09 Sep 2020 08:25:25 GMT" ); Server = ( cloudflare ); "Set-Cookie" = ( "__cfduid=d7a2a68ad15d1143f4043a51d15ce98aa1599639925; expires=Fri, 09-Oct-20 08:25:25 GMT; path=/; domain=.connectapi.garmin.com; HttpOnly; SameSite=Lax" ); "Www-Authenticate" = ( "OAuth realm=\"connect.garmin.com\"" ); "alt-svc" = ( "h3-27=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-29=\":443\"; ma=86400" ); "cf-cache-status" = ( DYNAMIC ); "cf-ray" = ( "5cff84bbd9ec1047-MRS" ); "cf-request-id" = ( 051391496b00001047da2bf200000001 ); "expect-ct" = ( "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"" ); } }, Response-Body=<!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Invalid nonce and timestamp</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Garmin Connect API Server</h3></body></html>, NSErrorFailingURLKey=https://connectapi.garmin.com/oauth-service/oauth/request_token, OAuthSwiftError.response.data={length = 1088, bytes = 0x3c21646f 63747970 65206874 6d6c3e3c ... 3e3c2f68 746d6c3e }}] ``` Code as follows... ``` self.oauthSwift = OAuth1Swift( consumerKey: HealthConfigurationService.getGarminConsumerKey(), consumerSecret: HealthConfigurationService.getGarminConsumerSecret(), requestTokenUrl: HealthConfigurationService.getGarminRequestTokenUrl(), authorizeUrl: HealthConfigurationService.getGarminAuthorizeUrl(), accessTokenUrl: HealthConfigurationService.getGarminAccessTokenUrl()) self.oauthSwift.addCallbackURLToAuthorizeURL = true self.oauthSwift.authorizeURLHandler = SafariURLHandler(viewController: UIApplication.shared.topMostViewController()!, oauthSwift: self.oauthSwift) self.oauthSwift.authorize( withCallbackURL: HealthConfigurationService.getGarminCallbackURL()) { result in switch result { case .success: print("success") case .failure(let error): print(error.description) } } ``` ### OAuth Provider? (Twitter, Github, ..): - Garmin ### OAuth Version: - [x] Version 1 - [ ] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [x] CocoaPods - [ ] Swift Package Manager - [ ] Manually ### Library version: - [x] head - [ ] v2.1.0 - [ ] v2.0.0 - [ ] v1.4.1 - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [x] 11.6 (Swift 5.2) - [ ] 11.4 (Swift 5.2) - [ ] 11.x (Swift 5.1) - [ ] 10.x (Swift 5.0) - [ ] other: (Please fill in the version you are using.) - [ ] objective c
kerem closed this issue 2026-03-03 16:48:26 +03:00
Author
Owner

@pepejeria commented on GitHub (Oct 29, 2020):

I have Garmin working just fine with OAuth1Swift and addCallbackURLToAuthorizeURL set to false (default).

<!-- gh-comment-id:718892778 --> @pepejeria commented on GitHub (Oct 29, 2020): I have Garmin working just fine with OAuth1Swift and `addCallbackURLToAuthorizeURL` set to false (default).
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#406
No description provided.