core.py¶
Main class for OSM login.
Source code in osm_login_python/core.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
login ¶
login()
Generate login URL from OSM session.
Provides a login URL using the session created by osm client id and redirect uri supplied.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
{'login_url': 'URL'} |
Source code in osm_login_python/core.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
callback ¶
callback(callback_url)
Performs token exchange between OSM and the callback website.
The returned data will be individually serialized and encoded, so it can only be used from within the same module.
The returned dictionary / JSON will contain:
- user_data
, containing OSM user details.
- oauth_token
, containing the OSM OAuth token for API calls.
To use these values, we must run them through the deserialize_data
function to deserialize and decode the data using the secret_key
variable set.
NOTE 'oauth_token' should not be stored in a frontend and can be discarded if not required. It could, however, be stored in a secure httpOnly cookie in the frontend if required, for subsequent API calls.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback_url(str) |
Absolute URL should be passed which is returned from login_redirect_uri. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The encoded user details and encoded OSM access token. |
Source code in osm_login_python/core.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
deserialize_data ¶
deserialize_data(data)
Returns the userdata as JSON from access token.
Can be used for login required decorator or to check the access token provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data(str) |
The user_data or oauth_token from Auth.callback() |
required |
Returns:
Name | Type | Description |
---|---|---|
deserialized_data |
dict
|
A deserialized JSON data. |
Source code in osm_login_python/core.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
options: show_source: false heading_level: 3