Skip to content

Authenticate member via access_token #57

@stefankip

Description

@stefankip

I've been looking for a way to authenticate a member when the access_token is supplied via query string for example.
So I have to authenticate without the use of any web api or MVC attribute.
For now I have this, but I had to copy over some internal stuff from the package, so I guess there should be a nicer way:

if (!string.IsNullOrEmpty(Request.QueryString["access_token"]))
{
    const string realm = "default";
    var oAuthContext = OAuth.GetContext(realm);
    var principal = oAuthContext.Services.TokenService.ReadToken(Request.QueryString["access_token"]);

    if (PrincipalHelper.ValidatePrincipal(principal, realm, oAuthContext.Services.UserService))
    {
        var name = principal.Identity.Name; // ToDo: log member in via username
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions