我想在我的应用程序中使用Outlook创建联系人。首先,我进入下面的这个URL
https://login.live.com/oauth20_authorize.srf?client_id='.$client_id.'&scope=wl.signin%20wl.basic%20wl.emails%20wl.contacts_emails%20wl.contacts_create&response_type=code&redirect_uri='.$redirect_uri
我希望这是获取令牌的旧方法,所以我
https://login.microsoftonline.com/daa825ce-e4fb-40d2-b2e6-3a2f25e62b7c/oauth2/token?client_id='.$client_id.'&scope=wl.signin%20wl.basic%20wl.emails%20wl.contacts_emails%20wl.contacts_create&response_type=code&redirect_uri='.$redirect_uri
所以我在下面收到此错误。
答案 0 :(得分:0)
要致电create contacts,请致电
POST https://graph.microsoft.com/v1.0/me/contacts
Content-type: application/json
{
"givenName": "Pavel",
"surname": "Bansky",
"emailAddresses": [
{
"address": "pavelb@fabrikam.onmicrosoft.com",
"name": "Pavel Bansky"
}
],
"businessPhones": [
"+1 732 555 0102"
]
}
您可以按照this document获取访问令牌。请记住要授予您的应用Contacts.ReadWrite
权限。
步骤2和步骤3中的范围应为https://graph.microsoft.com/Contacts.ReadWrite
更新:
要使用个人帐户,您需要设置以下支持的帐户类型
并且授权端点应该使用公用的,而不是指定的租户。
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?
client_id=562855f4-f3dd-40bb-b829-515ccb96ff3f
&response_type=code
&redirect_uri=http://localhost
&response_mode=fragment
&scope=https://graph.microsoft.com/Contacts.ReadWrite
&state=12345
也是令牌端点。
https://login.microsoftonline.com/common/oauth2/v2.0/token