-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow authenticated users to generate tokens via the UI #1016
base: 7.x-2.x
Are you sure you want to change the base?
Conversation
I made this addition to the module to make it easier for users to get a token for the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! An awesome feature @juampynr.
Just a couple of minor thoughts.
* @param array $form_state | ||
* The form state array. | ||
*/ | ||
function restful_token_auth_generate_token_form_validate($form, &$form_state) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?
*/ | ||
function restful_token_auth_generate_token_form($form, &$form_state, $uid) { | ||
$form['description'] = array( | ||
'#markup' => t('<p>You don\'t have an API key yet. Click below to generate one.</p>'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid markup in the translation string. Maybe consider #prefix
and #suffix
for this.
<p>Your authentication token is: <code><?php print $token; ?></code></p> | ||
|
||
<p>Discover the API by running the following command in a terminal and replacing | ||
[your-token] by the above string:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see [your-token]
anywhere. Maybe it's a stale comment?
|
||
<p> | ||
<code> | ||
curl -H 'access-token:<?php print $token; ?>' <?php print $GLOBALS['base_url'] ?>/api?all=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's better to have a preprocess function that uses url(…)
to set up a variable. Then we only need to print the variable here. The current code will fail if the site is installed in a subdir, or there is a language path prefix, etc.
I made this addition to the module to make it easier for users to get a token for the API.
Here is what a user would see at its profile:
And then, after generating the token: