简体   繁体   English

通过Oauth2进行身份验证

[英]Authentication through Oauth2

For getting results using Google Analytics, if I access the following URL: 为了使用Google Analytics(分析)获得结果,如果我访问以下URL:

https://www.googleapis.com/analytics/v3/data/ga?ids=gaxxxxx&start-date=2014-07-01&end-date=2014-07-15&metrics=gapageviews&dimensions=gapagePath&access_token= {YOUR_ACCESS_TOKEN} https://www.googleapis.com/analytics/v3/data/ga?ids=gaxxxxx&start-date=2014-07-01&end-date=2014-07-15&metrics=gapageviews&dimensions=gapagePath&access_token= {YOUR_ACCESS_TOKEN}

I get JSON response if and only if I get an access token using oauth2 playground and navigate to the URL mentioned above, but that access token is only valid for 1 hour, kindly tell how can I automatically authenticate using auth2 so need of access token is not there. 当且仅当我使用oauth2游乐场获取访问令牌并导航至上述URL时,我才会获得JSON响应,但是该访问令牌仅在1小时内有效,请告诉我如何使用auth2自动进行身份验证,因此需要访问令牌不在那里。 Thanx 谢谢

Store the token in the shared preferences in Android (or in persistent storage, in case of C#). 将令牌存储在Android中的共享首选项中(或在C#中存储在永久性存储中)。

If you get authenticated using that token, it's fine; 如果您使用该令牌进行了身份验证,那很好。 otherwise, request again and save the token again. 否则,再次请求并再次保存令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM