基于令牌的身份验证:应用程序与服务器(Token-based authentication: Application vs Server)
刚刚发现基于令牌的身份验证的基本工作流程如下:
- 用户通过提供用户名和密码来请求访问
- 应用程序验证凭据并将令牌返回给客户端
- 然后将令牌存储在客户端上,并随后与每个请求一起发送
- 然后, 服务器验证令牌并将私有数据作为响应返回
现在,我或多或少了解流程,但是,我遇到了应用程序 , 客户端和服务器这两个术语的问题。 我理解术语服务器是指存储API的位置......这也是应用程序的一部分。 但是应用程序也可以是从Web应用程序到各种平台上的移动应用程序......换句话说就是客户端 。
因此,应用程序包括服务器和客户端都不是真的。 那么,在上述背景下,每个术语的含义是什么?
再想一想......我猜原始令牌是在服务器端生成的,然后将其返回给客户端。 这是真的?
Just found out that the basic workflow for token-based authentication is as follows:
- User requests access by providing username and password
- The application validates the credentials and returns a token to the client
- The token is then stored on the client and sent with every request henceforth
- The server then validates the token and returns private data as a response
Now, I understand the flow more or less, however, I'm having issues with the terms application, client and server. I understand the term server to mean where the API is stored... which is also part of the application. But the application could also be anything from a web app to a mobile app on various platforms... a client in other words.
So isn't it true that the application includes both the server and the client. So what does it mean by each term exactly, in the above context?
On second thoughts... I guess the original token is being generated on the server side, and this is then being returned to the client. Is this true?
原文:https://stackoverflow.com/questions/39391391
最满意答案
根据上面的评论 - 在片段活动中覆盖onResume()方法
@Override protected void onResume() { TextView cartQry = (TextView) view.findViewById(R.id.actionbar_cart_qty); int count = ShoppingCart.getInstance().getTotalItems(); cartQry.setText(Integer.toString(count)); super.onResume(); }
As per the comment above - overrode onResume() Method in Fragment Activity
@Override protected void onResume() { TextView cartQry = (TextView) view.findViewById(R.id.actionbar_cart_qty); int count = ShoppingCart.getInstance().getTotalItems(); cartQry.setText(Integer.toString(count)); super.onResume(); }
相关问答
更多-
case android.R.id.home: 尝试使用此代替case R.id.home: case android.R.id.home: try to use this instead of case R.id.home:
-
使用网站转换不同大小的图像例如。 hdpi , mdpi , xhdpi等 并将您转换后的图像放入mipmap文件夹中 参考代码 : Toolbar toolbarTop = (Toolbar) findViewById(R.id.toolbar_top); TextView mTitle = (TextView) toolbarTop.findViewById(R.id.toolbar_title); mTitle.setText("Open Docket"); setSupp ...
-
我想你可以这样做: 创建一个通用片段: public abstract class extends BaseFragment { public abstract boolean onBackPressed(); } 在他的Fragments中,扩展了这个BaseFragment,例如: public class TopStoriesFragment extends BaseFragment { ... @Override public boolean onBac ...
-
塞尔文已经发布了正确的答案,这里只是解决方案的漂亮的代码;-) public class ServicesViewActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // etc... getActionBar().setDisplayHomeA ...
-
“up”可用性指标由主题的homeAsUpIndicator属性中指定的drawable提供。 要用自己的自定义版本来覆盖它,这将是这样的: 如果您在应用程序之前支持3.0之前,请确保将此版本的自定义主题 ...
-
你需要调用getActivity().invalidateOptionsMenu(); 用于更新您的optionMenu。 docs说: Declare that the options menu has changed, so should be recreated. The onCreateOptionsMenu(Menu) method will be called the next time it needs to be displayed Declare that the options menu ...
-
我想通了,我不得不在我的onMenuItemClicked函数中调用finish()而不是使用默认函数。 这个答案可能已经过时了。 I figured it out, I had to call finish() in my onMenuItemClicked function rather than using the default function. This answer may be outdated though.
-
你需要通过调用setHasOptionsMenu(true)来指示你的片段将处理选项菜单而不是持有者活动的android堆栈,并且文档建议将它放在你的片段的onCreate()回调中。 这将使您的日志消息被适当调用。 You need to instruct the android stack that your fragment will handle the options menu instead of the holder activity by calling setHasOptionsMenu( ...
-
根据上面的评论 - 在片段活动中覆盖onResume()方法 @Override protected void onResume() { TextView cartQry = (TextView) view.findViewById(R.id.actionbar_cart_qty); int count = ShoppingCart.getInstance().getTotalItems(); cartQry.setText(Integer.toString(count)); ...
-
首先,服务中没有后退按钮。 服务没有UI。 如果您的意思是活动,只需调用finish() 。 First of all, there are no back buttons in a service. A service does not have a UI. If you mean an activity, just call finish().