如何使用参数创建授权 URL 请求
How to create authorization URL request with paramters
我正在尝试与 yahoo Gemini 合作 api
首先需要使用 Ouath 2.0
来实现
进入这个link
它说我需要用 "Request Parameters"
创建对 URL 的请求
client_id
redirect_uri
现在假设我在 java:
这是我的 HTTP 请求:
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new
HttpPost("https://api.login.yahoo.com/oauth2/request_auth");
这是我向请求添加参数的方式吗?
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
params.add(new BasicNameValuePair("client_id", "ABCDEFGH"));
params.add(new BasicNameValuePair("redirect_uri", "http://www.goTo.Com"));
这是我执行整个请求的方式吗?
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
- 这是获得授权 URL 和授权访问的正确方法吗?
- 有没有其他方法/更简单的方法?
- 我应该期待什么响应?
我正在尝试与 yahoo Gemini 合作 api 首先需要使用 Ouath 2.0
来实现进入这个link
它说我需要用 "Request Parameters"
创建对 URL 的请求client_id
redirect_uri
现在假设我在 java:
这是我的 HTTP 请求:
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new
HttpPost("https://api.login.yahoo.com/oauth2/request_auth");
这是我向请求添加参数的方式吗?
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
params.add(new BasicNameValuePair("client_id", "ABCDEFGH"));
params.add(new BasicNameValuePair("redirect_uri", "http://www.goTo.Com"));
这是我执行整个请求的方式吗?
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
- 这是获得授权 URL 和授权访问的正确方法吗?
- 有没有其他方法/更简单的方法?
- 我应该期待什么响应?