Twitter OAuth

新浪微博和 Twitter 的 Oauth API 为什么感觉流程不一样

 

新浪:

  1. 开发者引导用户到新浪授权页面, 页面链接中需要带上自己的 apikey :
  2. 用户授权后新浪跳转到开发者指定指定的页面,并且附上服务器返回的一枚 code 作为 param ;
  3. 开发者用这枚 code ,再加上自己的 apikey 和 api secret 去 post https://api.weibo.com/oauth2/access_token ;
  4. post 返回 access_token;
  5. 以后开发者每次用这枚 access_token 请求用户资源。

Twitter:

  1. 开发者首先把自己的 apikey 等信息加密作为 Header 里面的 Authorization 去 post https://api.twitter.com/oauth/request_token?call_back=balabala , 获得 auth_token ;
  2. 开发者再把用户引导到 Twitter 授权页面,并且需要传入这枚 auth_token 作为参数;
  3. 用户授权后开发者再获得 oauth_token 和 oauth_verifier , 开发者再把这一步获得的 auth_token 和 第一步的进行校验;
  4. 开发者再拿上一步获得的 oauth_verifier 和 oauth_token 去 post https://api.twitter.com/oauth/access_token , 成功后获得 oauth_token, uid, username 这些,然后再自己解析获得 access_token 。
  5. 以后开发者每次用这枚 access_token 请求用户资源。

感觉 Twitter 的要麻烦, 主要就是在引导用户授权之前还要自己先去 post 服务器临时获得一枚 auth_token 。

 

 

 

官网Twitter OAuth

 

Twitter API开发与OAuth介绍

 

 

Question: How long does an access token last?

Answer: We do not currently expire access tokens. Your access token will be invalid if a user explicitly rejects your application from their settings or if a Twitter admin suspends your application. If your application is suspended there will be a note on your application page saying that it has been suspended.

 

 

 

Obtaining Ads Account Access

Single-user OAuth with Examples

Access Tokens

OAuth Trick in coding

Twitter libraries

API reference index

Securing keys and access tokens

 

 

 

 

posted @   PanPan003  阅读(968)  评论(0编辑  收藏  举报
编辑推荐:
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 没有源码,如何修改代码逻辑?
· NetPad:一个.NET开源、跨平台的C#编辑器
· 面试官:你是如何进行SQL调优的?
点击右上角即可分享
微信分享提示