我使用以下库为google oauth2 https://github.com/golang/oauth2
我正在使用示例中给出的代码(网址:http://play.golang.org/p/qXyuaVEhyS,https://godoc.org/golang.org/x/oauth2/google)
我能够获得auth代码和令牌,但无法获取获取用户信息的get请求
MyCode:
conf := &oauth2.Config{
ClientID: "my client id",
ClientSecret: "secred id",
RedirectURL: "http://localhost:3000/googlelogin",
Scopes: []string{
"https://www.googleapis.com/auth/userinfo.profile",
},
Endpoint: google.Endpoint,
}
m.Get("/googleloginrequest", func(r render.Render, request *http.Request) {
url := conf.AuthCodeURL("state")
fmt.Printf("Visit the URL for the auth dialog: %v", url)
r.Redirect(url)
})
m.Get("/googlelogin", func(r render.Render, request *http.Request) {
authcode := request.FormValue("code")
tok, err := conf.Exchange(oauth2.NoContext, authcode)
if err != nil {
log.Fatal(err)
}
client := conf.Client(oauth2.NoContext, tok)
resp, err :=client.Get("https://www.googleapis.com/userinfo/v2/me")
r.JSON(200, …Run Code Online (Sandbox Code Playgroud) 我试图通过应用程序中的路标实现OAuth,并发现本教程看起来像是基于eclipse. http://nilvec.com/implementing-client-side-oauth-on-android.html
相关说明:"我们将使用优秀的路标Java库来实现对Gmail的OAuth访问.只需至少下载signpost-core和signpost-commonshttp4 jar,将它们复制到Android项目内的lib /文件夹中,右键单击项目,在Properties/Java Build Path下,你可以将它们添加到构建路径:"
我尝试将提到的.jars移动到我的应用程序中的app/libs文件夹,没有运气.我是在正确的轨道还是有更好的方法来处理android studio中的OAuth?
我是Firebase的新手.我正在尝试将Google OAuth连接到我的Firebase实例.
我设置了一切,并获得客户端ID和客户端分泌.我将localhost添加到Firebase信息中心的白名单中.然后我使用了下面的Firebase示例:
<html>
<head>
<script src="https://cdn.firebase.com/js/client/2.0.4/firebase.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script>
var ref = new Firebase("https://<firebase url>.firebaseio.com");
ref.authWithOAuthRedirect("google", function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
}
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我打开它时,它会要求允许通过Google进行身份验证.当我接受它时,它只是继续进行重定向(无限)并且没有完成加载.对问题的任何见解都会有所帮助.谢谢.
编辑:我注意到:authWithOAuthPopup()方法有效但重定向只是停留在无限重定向循环中.
我有一个客户端.Net应用程序,它使用ADAL访问在azure上运行的Web API应用程序.
服务器具有自定义代码,用于验证用户是否属于特定安全组.
问题是我的用户属于太多组,导致AAD根本不包括令牌中的组列表.
因此,我的自定义代码再次调用AAD Graph API来验证用户是否属于该组 - 除了客户端为获取身份验证令牌而生成的用户.
有没有办法告诉AAD只返回组声明中的这一个特定组(以便AAD将其包含在令牌中)?
任何其他想法(除了我目前没有的缓存)将阻止我进行第二次通话将不胜感激.
想要为oauth登录生成签名.因为我使用了HmacSHA1和base64 algo.please看看下面代码的东西.我已经访问了很多与之相关的链接但是这给了java平台[ J2EE ]的解决方案而不是Android.同名代码/方法工作正常并在java的eclipse中生成签名但它在android中抛出错误.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.util.EntityUtils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View; …Run Code Online (Sandbox Code Playgroud) 我可以在没有浏览器(或应用程序中的嵌入式浏览器)的情况下使用OAuth 2.0进行每晚上传吗?
设置我有一个刷新令牌,可以从提供商控制台访问令牌-Google Drive API
我最初希望收到刷新/访问令牌后,便希望使用Java SDK使用/重用这些SDK来上传数据,而无需任何浏览器授权。
我目前已经设置了一个AAD实例,我正在通过我的网络应用程序对我的用户进行身份验证,并且它运行良好.
当我在AAD上添加和配置应用程序时,我添加了所需的应用程序和委派权限以访问Office365 Calendar API.但是,唯一缺少的是在登录流程期间,不会提示用户同意权限,因为它应该从我在您的文档中读到的内容发生:https://msdn.microsoft.com /en-us/library/azure/dn132599.aspx#BKMK_Consent
我不确定我错过了什么.显然,从文档来看,
用户登录后,Azure AD将确定是否需要向用户显示同意页面.此确定基于用户(或其组织的管理员)是否已授予应用程序同意.如果尚未授予同意,Azure AD将提示用户同意并显示其运行所需的权限.同意对话框中显示的权限集与Azure管理门户中其他应用程序控件的权限中选择的权限集相同.
所以也许某种程度上我可能已经暗中授予了这些权限的管理员同意,但我不知道是怎么回事.
我已经附加了我在AAD App上配置的权限.

任何帮助,将不胜感激.
我在我的restful Web服务中实现了Spring Security.实际上,我必须在客户端的请求中添加一个额外的参数,并且应该在请求认证/ accesstoken时从服务中获取它.
弹簧security.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sec="http://www.springframework.org/schema/security" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd ">
<!-- @author Nagesh.Chauhan(neel4soft@gmail.com) -->
<!-- This is default url to get a token from OAuth -->
<http pattern="/oauth/token" create-session="stateless"
authentication-manager-ref="clientAuthenticationManager"
xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" />
<anonymous enabled="false" />
<http-basic entry-point-ref="clientAuthenticationEntryPoint" />
<!-- include this only if you need to authenticate clients via request
parameters -->
<custom-filter ref="clientCredentialsTokenEndpointFilter"
after="BASIC_AUTH_FILTER" />
<access-denied-handler ref="oauthAccessDeniedHandler" />
</http> …Run Code Online (Sandbox Code Playgroud) 我在我的restful web服务中实现了spring security.
OAuth请求访问令牌
作为响应,我将获得访问令牌和刷新令牌.
现在我可以通过以下查询字符串参数方法请求具有给定访问令牌的API服务.并且完美地工作.
请求格式
在上面的快照我有
JSON格式请求除外access_token.
{
"mainCategory":"Deals",
"subCategory":"Vigo"
}
Run Code Online (Sandbox Code Playgroud)
实际上我必须使用以下格式.
{
"mainCategory":"Deals",
"subCategory":"Vigo",
"access_token":"122356545555"
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试这个时,它会抛出错误
<oauth>
<error_description>
An Authentication object was not found in the SecurityContext
</error_description>
<error>
unauthorized
</error>
</oauth>
Run Code Online (Sandbox Code Playgroud)
弹簧security.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sec="http://www.springframework.org/schema/security" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd ">
<!-- This is default url to get a token from OAuth -->
<http pattern="/oauth/token" create-session="stateless" …Run Code Online (Sandbox Code Playgroud) 我需要OAuth在我的Android应用程序中使用协议.我决定使用android-oauth-client.在我的build.gradle档案中,我有:
dependencies {
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.wu-man:android-oauth-client:0.0.3'
}
Run Code Online (Sandbox Code Playgroud)
使用gradle文件同步项目工作正常,但是当我尝试构建我的应用程序时,存在一个问题:
错误:任务':app:dexDebug'的执行失败.com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'C:\ Program Files\Java\jdk1.7.0_51\bin\java.exe''以非完成零退出值2
我发现,我应该尝试添加multiDexEnabled true的defaultConfig部分build.gradle.第一个问题已经解决,但还有另一个问题:
错误:任务':app:packageAllDebugClassesForMultiDex'的执行失败.java.util.zip.ZipException:重复条目:android/support/v4/accessibilityservice/AccessibilityServiceInfoCompat $ AccessibilityServiceInfoIcsImpl.class
我不知道如何修复它以及如何构建我的项目.你能帮我吗?提前致谢.