我正在尝试使用以下命令访问 spotify 令牌
OkHttpClient client = new OkHttpClient();
String state = "azertyuiopmlkjhg";//TODO random string
String scope = "user-read-private user-read-email";
URIBuilder ub = new URIBuilder("https://accounts.spotify.com/authorize?")
.addParameter("client_id", CLIENT_ID)
.addParameter("response_type", "token")
.addParameter("scope", scope)
.addParameter("redirect_uri", REDIRECT_URI)
.addParameter("state", state);
String url = ub.toString();
System.out.println(url);
Request request = new Request.Builder()
.header("Content-Type", "application/json")
.url(url)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
final String myResponse = response.body().string();
final String networkResponse = response.networkResponse().request().url().toString();
System.out.println(myResponse);
System.out.println(networkResponse);
if (response.isSuccessful()) {
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
textView.setText("Success \n"+myResponse);
}
});
}
}
});
生成的网址< code > https://accounts . Spotify . com/authorize?client_id=e...0
查询返回值应为:access_token;标记类型;expires_in和state但我得到了一些HTML作为响应
<html id="app" lang="fr" dir="ltr" ng-csp ng-strict-di>
<head>
<meta charset="utf-8">
<title ng-bind="('loginTitle' | localize) + ' - Spotify'">Spotify</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<base href="/">
<link rel="icon" href="https://accounts.scdn.co/sso/images/favicon.ace4d8543bbb017893402a1e9d1ac1fa.ico">
<link href="https://accounts.scdn.co/sso/css/index.daf98bb304f1ca0e3987.css" media="screen" rel="stylesheet">
<script defer src="https://accounts.scdn.co/sso/js/index.daf98bb304f1ca0e3987.js" sp-bootstrap></script>
<meta ng-non-bindable sp-bootstrap-data='{"phoneFeatureEnabled":false,"previewEnabled":false,"user":false,"tpaState":"AQ...Q=","BON":["0","0",136907053]}'>
</head>
<body ng-controller="LoginController">
<div ng-include="template"></div>
</body>
</html>
最后,我按照下面的教程,使用了spotify认证服务
请注意,AuthenticationRequest和AuthenticationClient现在称为AuthorizationRequest和AuthorizationClient
这是spotify的身份验证流示例
https://github.com/yschimke/okurl/blob/0abaa8510dd5466d5e9a08ebe33a009c491749bf/src/main/kotlin/com/baulsupp/okurl/services/spotify/SpotifyAuthFlow.kt
val scopesString = URLEncoder.encode(scopes.joinToString(" "), "UTF-8")
val loginUrl =
"https://accounts.spotify.com/authorize?client_id=$clientId&response_type=code&state=x&redirect_uri=${s.redirectUri}&scope=$scopesString"
outputHandler.openLink(loginUrl)
val code = s.waitForCode()
val tokenUrl = "https://accounts.spotify.com/api/token"
val body = FormBody.Builder().add("client_id", clientId)
.add("redirect_uri", s.redirectUri)
.add("code", code)
.add("grant_type", "authorization_code")
.build()
val request = Request.Builder().header(
"Authorization",
Credentials.basic(clientId, clientSecret)
)
.url(tokenUrl)
.method("POST", body)
.build()
val responseMap = client.queryMap<Any>(request)
return Oauth2Token(
responseMap["access_token"] as String,
responseMap["refresh_token"] as String, clientId, clientSecret
)
$ okurl --authorize=spotify
Accounts: https://developer.spotify.com/my-applications/
Spotify Client Id []: xxx
Spotify Client Secret []:
Scopes [playlist-read-private,playlist-read-collaborative,playlist-modify-public,playlist-modify-private,streaming,ugc-image-upload,user-follow-modify,user-follow-read,user-library-read,user-library-modify,user-read-private,user-read-birthdate,user-read-email,user-top-read]:
我正在写一个Android(版本ICS)应用程序。它将数据上传到谷歌驱动器。应用程序使用oauth2获取访问令牌。 第一步:获取授权令牌。
问题内容: 我已经使用 Laravel Passport文档* 成功创建了 server.app 和 client.app 。一切正常。 * client.app路线: 默认情况下,此路由返回 access_token ,我可以用它执行我想做的任何事情。 请求: 返回值: 题: 如何使用 client.app中* 给定的access_token 向 server.app 发出正确请求,以获取例如
获取访问令牌的文档中的第一步是“将用户引导到我们的授权URL”。那到底是什么意思?没有提供链接或任何东西。它还说“公司名称、联系电子邮件和隐私政策URL是开始提交的必要条件。”我们的应用程序没有隐私政策...只是一个简单的标签提要。我不明白为什么有一个简单的标签提要那么复杂。 是否有一个等待时间来获得批准的应用程序..如果它得到批准...在获得访问令牌之前,我必须获得批准吗?这在任何地方都没有概述
发布https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token http/1.1 但无法访问https://graph.microsoft.com/v1.0/users/{id}/calendars。我得到的信息与此类似:
我试图使用从Spring应用程序中的公共客户端获取访问令牌。 谁能帮我弄清楚我做错了什么吗?
我的主要目的是通过单个管理员访问令牌获取用户的日历。我正在尝试按照以下步骤获取访问令牌。 URL:https://login.microsoftonline.com/{tenentId}/oaust2/v2.0/令牌正文client_id:client_ID范围:https://graph.microsoft.com/.defaultclient_secret:client_secretIDgra