Skip to content
This repository has been archived by the owner on Dec 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #12 from naasir/master
Browse files Browse the repository at this point in the history
Fixed bug with reading access token from authorization header
  • Loading branch information
Micah Martin committed Jan 11, 2013
2 parents 9063fec + b84fe43 commit 7f8ef60
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/OAuth2Provider/Request/OAuthRequestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
using OAuth2Provider;

namespace OAuth2Provider.Request
{
{
using System.Linq;

public abstract class OAuthRequestBase : IOAuthRequest
{
private readonly IRequest _request;
Expand Down Expand Up @@ -68,9 +70,9 @@ public string AccessToken
if (!string.IsNullOrWhiteSpace(accessToken))
return accessToken;

var authHeader = _request.Headers.SafeGet(HeaderType.Authorization) + "";
if(authHeader.Contains("OAuth") || authHeader.Contains("Bearer"))
accessToken = authHeader.Replace("OAuth ", "").Replace("Bearer ", "").Trim();
var authHeader = _request.Headers.SafeGet(HeaderType.Authorization).FirstOrDefaultSafe() ?? string.Empty;
if (authHeader.Contains("OAuth") || authHeader.Contains("Bearer"))
accessToken = authHeader.Replace("OAuth ", string.Empty).Replace("Bearer ", string.Empty).Trim();

return accessToken;
}
Expand Down

0 comments on commit 7f8ef60

Please sign in to comment.