
auth_stackoverflow.pl -- Enable login with stackexchange
This module allows for configures _login with Stack exchange. To enable
this module:
- Follow these steps to
register your application on Stack Apps. Get the following info:
- The client ID
- The client secret
- The key
- Register a redirect url. To test from localhost, this should be
http://localhost:3050/oauth2/stackexchange/reply
- COPY this file to
config-enabled
- EDIT the server attributes
oauth2:server_attribute(?ServerID, ?Attribute, ?Value)[multifile]- Declare properties of an oauth2 identity provider. The values below
are for StackExchange server.
EDIT:
- url: base URL of the stackexchange authentication server
- api_endpoint: Stack Apps API endpoint
- redirect_uri: our location
- client_id: Client Id from Stack Apps
- client_secret: Client Secret from Stack Apps
- key: Key from Stack Apps to access their API (/me)
- site: Stack exchange site for which to ask info
- See also
- - swish(lib/oauth2) for a description of the attributes.
stackexchange_me(+AccessToken, -Info)[private]- Stack exchange does not support the oauth2
user_info
endpoint.
Instead, we must use the =/me= API. This is a little unlucky as we
need to duplicate some infrastructure from the generic oauth2.pl
module.
read_reply2(+Code, +ContentType, +Stream, -Dict) is det[private]- Read the server reply as a dict. Normally, the reply is a JSON
object, but stackexchange seems to send it as a www-form-encoded
string.
stackexchange_logout(+Request)[private]- Logout by removing the session data
swish_config:user_info(+Request, ?Server, -Info:dict) is semidet[multifile]- True if Info represents describes the currently logged in user.
map_user_info(+OAuthInfo, -UserInfo) is det[private]- u{user:User, group:Group, name:Name, email:Email}
uri_extend(+Base:atom, +Rel:atom, +Query:list, -URI:atom) is det[private]- Create a URI from Base, A relative URI and a query.
uri_extend_query(+URI0:atom, +Query:list, -URI:atom) is det[private]- Extend a URI with a query. If URI0 already has a query, keep all
parameters that do not conflict.