access_token_extractor v0.1.0 AccessTokenExtractor
Simple Plug to extract access_token from request and add it to private map in Plug.Conn struct. Access token must be provided as query param named access_token or should be provided as authorization header
Example:
http://some_url.com?access_token=abc
OR
authorization: Token token=abc
This plug will extract token provided in any of above ways as assign it to private map in Plug.Conn struct
You can access it using conn.private.access_token
‘access_token’ is the default key used. You can provide the custom key to used when using plug
Example:
def MyModule
import Plug.Builder, only: [plug: 1]
import AccessTokenExtractor
# second argument is optional. By default key is access_token
plug :AccessTokenExtractor, key: :token
end
In above example access_token can be retrived as conn.private.token. where conn is Plug.Conn struct