Skip to content

Commit fcbd67a

Browse files
authored
Call to Coinbase user profile should be a GET request (#558)
1 parent 7abc0ec commit fcbd67a

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/AspNet.Security.OAuth.Coinbase/CoinbaseAuthenticationHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
3434
[NotNull] AuthenticationProperties properties,
3535
[NotNull] OAuthTokenResponse tokens)
3636
{
37-
using var request = new HttpRequestMessage(HttpMethod.Post, Options.UserInformationEndpoint);
37+
using var request = new HttpRequestMessage(HttpMethod.Get, Options.UserInformationEndpoint);
3838
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
3939
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokens.AccessToken);
4040

@@ -53,7 +53,7 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
5353
using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync(Context.RequestAborted));
5454

5555
var principal = new ClaimsPrincipal(identity);
56-
var context = new OAuthCreatingTicketContext(principal, properties, Context, Scheme, Options, Backchannel, tokens, payload.RootElement);
56+
var context = new OAuthCreatingTicketContext(principal, properties, Context, Scheme, Options, Backchannel, tokens, payload.RootElement.GetProperty("data"));
5757
context.RunClaimActions();
5858

5959
await Options.Events.CreatingTicket(context);

test/AspNet.Security.OAuth.Providers.Tests/Coinbase/bundle.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@
1414
},
1515
{
1616
"uri": "https://api.coinbase.com/v2/user",
17-
"method": "POST",
17+
"method": "GET",
1818
"contentFormat": "json",
1919
"contentJson": {
20-
"id": "9da7a204-544e-5fd1-9a12-61176c5d4cd8",
21-
"email": "[email protected]",
22-
"name": "John Smith",
23-
"username": "jsmith",
24-
"profile_location": "test",
25-
"profile_bio": "test",
26-
"profile_url": "https://coinbase.com/jsmith",
27-
"avatar_url": "https://images.coinbase.com/avatar?h=vR%2FY8igBoPwuwGren5JMwvDNGpURAY%2F0nRIOgH%2FY2Qh%2BQ6nomR3qusA%2Bh6o2%0Af9rH&s=128"
20+
"data": {
21+
"id": "9da7a204-544e-5fd1-9a12-61176c5d4cd8",
22+
"email": "[email protected]",
23+
"name": "John Smith",
24+
"username": "jsmith",
25+
"profile_location": "test",
26+
"profile_bio": "test",
27+
"profile_url": "https://coinbase.com/jsmith",
28+
"avatar_url": "https://images.coinbase.com/avatar?h=vR%2FY8igBoPwuwGren5JMwvDNGpURAY%2F0nRIOgH%2FY2Qh%2BQ6nomR3qusA%2Bh6o2%0Af9rH&s=128"
29+
}
2830
}
2931
}
3032
]

0 commit comments

Comments
 (0)