谷歌飞度阿比从远程客户端403错误 [英] Google Fit Api 403 Error from remote client

查看:142
本文介绍了谷歌飞度阿比从远程客户端403错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有托管IIS 7的Web应用程序,正在做的Http使用谷歌飞度API调用,我能够成功发送POST和检索访问令牌,之后我做了以下URI的GET:

I have a web app hosted on IIS 7 that is doing Http calls using the Google Fit API, I'm able to successfully send a POST and retrieve an access token, after which I do a GET for the following uri:

<一个href=\"https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:com.google.android.apps.fitness:user_input/datasets/00-1427209862000000000\" rel=\"nofollow\">https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:com.google.android.apps.fitness:user_input/datasets/00-1427209862000000000\"

下面是我如何建立一个请求,并期待在响应:

Here's how I build a request and look at the response:

        request = (HttpWebRequest)WebRequest.Create(uri);
        request.Method = "GET";
        request.ContentLength = 0;
        request.Accept = "application/json";
        request.Headers.Add("Authorization", "Bearer " + dict["access_token"]);
        response = (HttpWebResponse)request.GetResponse();
        respStream = response.GetResponseStream();
        sResponse = new StreamReader(respStream).ReadToEnd();
        respStream.Close();
        Response.Write(sResponse);

当我运行在主机服务器上的浏览器这个程序,我顺利拿到一个JSON对象(它不是我期待的JSON,但那是另一个问题)。然而,当我尝试访问该网站的远程客户端上,我得到一个403错误指向,当我尝试检索响应。任何想法?

When I run this app on a browser on the host server, I successfully get a json object (it isn't the json I expect, but that's another issue). However, when I try to access the site on a remote client, I get a 403 error pointing to when I try to retrieve the response. Any ideas?

推荐答案

更​​新:事实证明,这是一个权限问题。我试图访问我没有作用域的数据源,但事实上,在主机上访问时,它没有返回403把我摔下的踪迹。仍然奇怪的是,它没有返回403当主机服务器上的请求,虽然......如果你看到这一点,有一个想法,为什么,随意评论(它只是返回一个空的JSON对象)。我很好奇。

Update: This turned out to be a permissions issue. I was trying to access a data source that I didn't have scopes for, the fact that it didn't return a 403 when accessing on the host threw me off the trail. Still strange that it didn't return a 403 (it just returned an empty json object) when requested on the host server though...if you see this and have an idea why, feel free to comment. I'm curious.

这篇关于谷歌飞度阿比从远程客户端403错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆