- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
在 sqaureup 应用程序 Aplication_name
的 oauth 选项中,有一个重定向 url,它将使用 QueryString 代码重定向给定的 url。当我在浏览器中点击 https://connect.squareup.com/oauth2/authorize?client_id=YOUR_CLIENT_ID
这个 url 时,它会将我重定向到带有附加代码的 oauth 中的给定 url。然后要获取 access_token
,您必须向给定的 url https://connect.squareup.com/oauth2/token
发出 POST
请求与 body
{
"client_id": "YOUR_APPLICATION_ID",
"client_secret": "YOUR_APPLICATION_SECRET",
"code": "M-Q7k-N0Emx_3cBqwbVLTQ",
"redirect_uri": "YOUR_REDIRECT_URI"
}
我也这样做,并通过方法 POST
将 json 数据发送到此 url,但它会给我错误:-
{
"message": "Not Authorized",
"type": "service.not_authorized"
}
我为此使用的 Golang 代码是:-
func Token(c *gin.Context) {
code := c.Query("code") // code be something like:-sq0cgp-wLVQt5HOLfug6xiVdmCDCf
splitCode := strings.Split(code, "-")
token := models.PostToken{
ClientID: "YOUR_APPLICATION_ID",
ClientSecret: "YOUR_APPLICATION_SECRET",
Code: splitCode[1],
RedirectUri: c.Request.Host + c.Request.URL.RequestURI(),
}
bindData, err := json.Marshal(token)
if err != nil {
panic(err)
}
var jsonStr = []byte(string(bindData))
url := "https://connect.squareup.com/oauth2/token"
req, err := http.Post(url, "application/json", bytes.NewBuffer(jsonStr))
fmt.Println(req, err)
}
模型结构:-
type PostToken struct {
ClientID string `json:"client_id" bson:"client_id"`
ClientSecret string `json:"client_secret" bson:"client_secret"`
Code string `json:"code" bson:"code"`
RedirectUri string `json:"redirect_uri" bson:"redirect_uri"`
}
最佳答案
你必须做我提到的一些点:-
ClientSecret
中,您必须使用 Oauth Application Secret key ,您可以从应用程序仪表板 -> Oauth 选项中获得该 key 。Code
中,您没有发送拆分代码发送您在变量名 code
中获取的简单字符串代码值。然后你会得到你想要的:D。
关于security - 如何使用后端 golang 通过 squareup 进行身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53718902/
我是 Square 的新手,正在尝试让他们的简单 SqPaymentForm 在 Tomcat/Eclipse/Firefox 下工作。当表单出现时,我收到以下加载被拒绝的错误。 iFrame 似乎可
我正在尝试实现类似于 Square's website 上的文本输入.本质上,具有 的输入在他们中。当您在其中单击时,文本会变浅,而当您开始输入时,它会消失。我之前找到了一个片段,但因为它是 pos
我正在尝试通过 OKhttp 缓存 http 响应但无法找到一些好的示例或文档。 感谢您的帮助 最佳答案 这会将您的所有响应缓存 2 分钟 OkHttpClient provideOkHttpClie
我正在开发一个用于练习的 Android 应用程序,它使用天气 API 并在屏幕上显示当前天气数据。它应该使用 Picasso 在 ImageView 元素上显示当前天气状态的天气图标。但是,Andr
我正在尝试在导入的Android Studio中编译一个Android项目: com.squareup.okhttp.HttpResponseCache 我收到错误消息“无法解析符号'HttpResp
Cordova.jar包含com.squareup.okhttp包,而我正在使用的第三方库也包含此包,因为该库正在使用grpc。如果我从第三方库中排除okhttp软件包,则启动库功能后应用程序将崩溃。
我正在尝试配置我的 Android 应用程序以使用 Firebase Cloud Firestore。我也依赖于 OKHttp3。 Gradle 可以正常同步,但我无法编译并运行该应用程序。我收到以下
在使用 Android Studio 运行我的代码时,它会生成此错误: Warning: Conflict with dependency 'com.squareup.okio: okio'. Res
我正在开发 android studio 并从网络上获取一些数据。我尝试使用 OkHttpClient 并将 jars 添加到我的项目文件夹,但我仍然无法导入它。 它显示无法解析符号 okhttp。我
我正在为 Woocommerce 开发 Square Connect 支付网关。 这是给我嵌入网关的网关文件和信用卡表格。 https://docs.connect.squareup.com/arti
在 sqaureup 应用程序 Aplication_name 的 oauth 选项中,有一个重定向 url,它将使用 QueryString 代码重定向给定的 url。当我在浏览器中点击 https
我正在使用 golang 在 squareup.com 中添加客户,但它总是说授权问题 谁能告诉我我的代码中有什么问题:- func Token(c *gin.Context) { code :=
我在运行低于 API 版本 21 的手机上遇到 noClassDefFoundError。首先它与其他类一起出现,在删除所有可能的代码后,它开始与 Picasso 库一起出现。我附上了我的 logca
当我尝试编译代码时,Android Studio 3.2.1上出现以下错误 Program type already present: com.squareup.picasso.Action$Requ
我想制作一个像 squareup.com 中的那样的 jquery 图像 slider 有没有类似的图片 slider 插件?我的意思是左边和右边都不受限制。或者你能给我修改其他插件来做到这一点的方法
我有一个使用 SquareUp 的 SqPaymentForm() 的付款表格。它将 iFrame 嵌入结帐页面。问题是 CVV 字段只允许三位数。这是美国运通卡持卡人的问题。 作为 squp 托管的
我在尝试使 google-maps-services-0.1.17.jar 正常工作时遇到问题 ( https://github.com/googlemaps/google-maps-services
我读过这个问题 Android http connecting with OkHttp Dont work和 NoClassDefFoundError for OkHttpClient但它并没有解决我
所以我正在尝试通过 android studio 设置 Square Reader SDK,并且在尝试完成“配置构建依赖项”中的第 3 步时遇到此错误 我正在关注 https://docs.conne
改造文档说: “默认情况下,Retrofit 只能将 HTTP 主体反序列化为 OkHttp 的 ResponseBody...可以添加转换器以支持其他类型” 这意味着我应该能够使用 GSON 转换器
我是一名优秀的程序员,十分优秀!