OAuth Tag

If you're using OAuth to manage user authentication, you may find you need to generate login URLs at some point. Here's how you do it.

Examples

Here’s the regular/parameter syntax in action, especially useful if the provider name comes from variable.

<a href="{{ oauth provider="github" }}">Sign In with Github</a>
<a href="/oauth/github">Sign In with Github</a>

And the shorthand version.

<a href="{{ oauth:github }}">Sign In with Github</a>
<a href="/oauth/github">Sign In with Github</a>

And now with a redirect:

<a href="{{ oauth:github redirect="/account" }}">Sign In with Github</a>
<a href="/oauth/github?redirect=/account">Sign In with Github</a>

Parameters

provider string|tagpart

The provider to be used. You may either specify as a parameter or as a tagpart for shorthand: {{ oauth provider="github" }} or {{ oauth:github }}

redirect string

The URL to be taken to after authenticating. This will be appending onto the generated URL as a query parameter.

Betterify this page on Github!