[GH-ISSUE #711] Trying to use different JSON properties in token result #460

Open
opened 2026-03-03 16:48:50 +03:00 by kerem · 1 comment
Owner

Originally created by @holgerflick on GitHub (Jan 11, 2024).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/711

Description:

I am unable to create a token POST request as the server seems to use different JSON properties than the framework. I have searched the code and I also looked into the documentation. I cannot find anything to solve this.

Instead of grant_type, they use GrantType. Is there a way to map the property names to custom names that I have missed? Error message below.

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

Custom third party database which has not been released yet.

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:

  • 15.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

Error Domain=OAuthSwiftError Code=400 "" UserInfo={OAuthSwiftError.response=<NSHTTPURLResponse: 0x6000002b54c0> { URL: https://.../token } { Status Code: 400, Headers {
    "Content-Length" =     (
        371
    );
    "Content-Type" =     (
        "application/json; charset=utf-8"
    );
    Date =     (
        "Thu, 11 Jan 2024 05:09:17 GMT"
    );
    Server =     (
        "Microsoft-IIS/10.0"
    );
} }, OAuthSwiftError.response.data={length = 371, bytes = 0x7b226d65 73736167 6573223a 5b7b2263 ... 223a6661 6c73657d }, Response-Body={"messages":[{"code":"BadRequest","message":"The GrantType field is required.","type":30},{"code":"BadRequest","message":"The RedirectUri field is required.","type":30},{"code":"BadRequest","message":"One of the values in field RedirectUri is not a valid url.","type":30},{"code":"BadRequest","message":"The ClientSecret field is required.","type":30}],"isSuccess":false}, NSLocalizedDescription=, Response-Headers={
    "Content-Length" = 371;
    "Content-Type" = "application/json; charset=utf-8";
    Date = "Thu, 11 Jan 2024 05:09:17 GMT";
    Server = "Microsoft-IIS/10.0";
}, NSErrorFailingURLKey=https://.../oauth/token}]
Originally created by @holgerflick on GitHub (Jan 11, 2024). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/711 ### Description: I am unable to create a token POST request as the server seems to use different JSON properties than the framework. I have searched the code and I also looked into the documentation. I cannot find anything to solve this. Instead of `grant_type`, they use `GrantType`. Is there a way to map the property names to custom names that I have missed? Error message below. ### OAuth Provider? (Twitter, Github, ..): Custom third party database which has not been released yet. ### OAuth Version: - [ ] Version 1 - [X] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [ ] CocoaPods - [X] 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] 15.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 ``` Error Domain=OAuthSwiftError Code=400 "" UserInfo={OAuthSwiftError.response=<NSHTTPURLResponse: 0x6000002b54c0> { URL: https://.../token } { Status Code: 400, Headers { "Content-Length" = ( 371 ); "Content-Type" = ( "application/json; charset=utf-8" ); Date = ( "Thu, 11 Jan 2024 05:09:17 GMT" ); Server = ( "Microsoft-IIS/10.0" ); } }, OAuthSwiftError.response.data={length = 371, bytes = 0x7b226d65 73736167 6573223a 5b7b2263 ... 223a6661 6c73657d }, Response-Body={"messages":[{"code":"BadRequest","message":"The GrantType field is required.","type":30},{"code":"BadRequest","message":"The RedirectUri field is required.","type":30},{"code":"BadRequest","message":"One of the values in field RedirectUri is not a valid url.","type":30},{"code":"BadRequest","message":"The ClientSecret field is required.","type":30}],"isSuccess":false}, NSLocalizedDescription=, Response-Headers={ "Content-Length" = 371; "Content-Type" = "application/json; charset=utf-8"; Date = "Thu, 11 Jan 2024 05:09:17 GMT"; Server = "Microsoft-IIS/10.0"; }, NSErrorFailingURLKey=https://.../oauth/token}] ```
Author
Owner

@phimage commented on GitHub (Jan 11, 2024):

no way to override key
easy way to do it could be create your own fork

most better way could be set in OAuthSwift2 a grantTypeKey = "grant_key",
use it when needed in code
and the var could be edited oauthSwift.grantTypeKey="GrantType"

and even better way maybe a call back function if exist to map all used key

Le jeu. 11 janv. 2024 à 06:22, Dr. Holger Flick @.***>
a écrit :

Description:

I am unable to create a token POST request as the server seems to use
different JSON properties than the framework. I have searched the code and
I also looked into the documentation. I cannot find anything to solve this.

Instead of grant_type, they use GrantType. Is there a way to map the
property names to custom names that I have missed? Error message below.
OAuth Provider? (Twitter, Github, ..):

Custom third party database which has not been released yet.
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:

15.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

Error Domain=OAuthSwiftError Code=400 "" UserInfo={OAuthSwiftError.response=<NSHTTPURLResponse: 0x6000002b54c0> { URL: https://api.stellardb.io/v1/oauth/token } { Status Code: 400, Headers {
"Content-Length" = (
371
);
"Content-Type" = (
"application/json; charset=utf-8"
);
Date = (
"Thu, 11 Jan 2024 05:09:17 GMT"
);
Server = (
"Microsoft-IIS/10.0"
);
} }, OAuthSwiftError.response.data={length = 371, bytes = 0x7b226d65 73736167 6573223a 5b7b2263 ... 223a6661 6c73657d }, Response-Body={"messages":[{"code":"BadRequest","message":"The GrantType field is required.","type":30},{"code":"BadRequest","message":"The RedirectUri field is required.","type":30},{"code":"BadRequest","message":"One of the values in field RedirectUri is not a valid url.","type":30},{"code":"BadRequest","message":"The ClientSecret field is required.","type":30}],"isSuccess":false}, NSLocalizedDescription=, Response-Headers={
"Content-Length" = 371;
"Content-Type" = "application/json; charset=utf-8";
Date = "Thu, 11 Jan 2024 05:09:17 GMT";
Server = "Microsoft-IIS/10.0";
}, NSErrorFailingURLKey=https://api.stellardb.io/v1/oauth/token}]


Reply to this email directly, view it on GitHub
https://github.com/OAuthSwift/OAuthSwift/issues/711, or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACDW56BR5O3IXB7TEPTGDXDYN5ZILAVCNFSM6AAAAABBV4TRTWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3TKNZXGU2TCMY
.
You are receiving this because you are subscribed to this thread.Message
ID: @.***>

<!-- gh-comment-id:1886745283 --> @phimage commented on GitHub (Jan 11, 2024): no way to override key easy way to do it could be create your own fork most better way could be set in OAuthSwift2 a grantTypeKey = "grant_key", use it when needed in code and the var could be edited oauthSwift.grantTypeKey="GrantType" and even better way maybe a call back function if exist to map all used key Le jeu. 11 janv. 2024 à 06:22, Dr. Holger Flick ***@***.***> a écrit : > Description: > > I am unable to create a token POST request as the server seems to use > different JSON properties than the framework. I have searched the code and > I also looked into the documentation. I cannot find anything to solve this. > > Instead of grant_type, they use GrantType. Is there a way to map the > property names to custom names that I have missed? Error message below. > OAuth Provider? (Twitter, Github, ..): > > Custom third party database which has not been released yet. > 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: > > - > > 15.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 > > Error Domain=OAuthSwiftError Code=400 "" UserInfo={OAuthSwiftError.response=<NSHTTPURLResponse: 0x6000002b54c0> { URL: https://api.stellardb.io/v1/oauth/token } { Status Code: 400, Headers { > "Content-Length" = ( > 371 > ); > "Content-Type" = ( > "application/json; charset=utf-8" > ); > Date = ( > "Thu, 11 Jan 2024 05:09:17 GMT" > ); > Server = ( > "Microsoft-IIS/10.0" > ); > } }, OAuthSwiftError.response.data={length = 371, bytes = 0x7b226d65 73736167 6573223a 5b7b2263 ... 223a6661 6c73657d }, Response-Body={"messages":[{"code":"BadRequest","message":"The GrantType field is required.","type":30},{"code":"BadRequest","message":"The RedirectUri field is required.","type":30},{"code":"BadRequest","message":"One of the values in field RedirectUri is not a valid url.","type":30},{"code":"BadRequest","message":"The ClientSecret field is required.","type":30}],"isSuccess":false}, NSLocalizedDescription=, Response-Headers={ > "Content-Length" = 371; > "Content-Type" = "application/json; charset=utf-8"; > Date = "Thu, 11 Jan 2024 05:09:17 GMT"; > Server = "Microsoft-IIS/10.0"; > }, NSErrorFailingURLKey=https://api.stellardb.io/v1/oauth/token}] > > — > Reply to this email directly, view it on GitHub > <https://github.com/OAuthSwift/OAuthSwift/issues/711>, or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ACDW56BR5O3IXB7TEPTGDXDYN5ZILAVCNFSM6AAAAABBV4TRTWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3TKNZXGU2TCMY> > . > You are receiving this because you are subscribed to this thread.Message > ID: ***@***.***> >
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#460
No description provided.