How can I get my apps authenticated by Grafana Service?

I write a program that accesses to Grafana, and
get alert info in json-format.

However,this program returns the following message.
Along with tutrial on the official site,
I added authentication info that specifies api key I generated to Http-Request header,Grafana may not recognize it.


message “Unauthorized”

Envirment
OS :Linux Mint 18.2
Grafana:v5.0.0(without Apache)

CODE in Python

#coding:utf-8
import json, urllib2
import requests

iparams={‘Authorization’:’ Bearer '}

url = ‘http://myserver/api/alerts

try:
# add api-key to the request header.
response = requests.get(url, params=iparams)

except Exception, e:
print e

Hi,

You need to add your generated api key to the end of Bearer, like Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Marcus

Thanks you, mefraisson,

I got wrong in the way how to my generated key to the App.
I should the key not to params, but to headers.
[Wrong Way]

add api-key to the request header.

response = requests.get(url, params=iparams)

[Corrected Way]

add api-key to the request header.

response = requests.get(url, headers=iparams)

after adding the key to headers,
my Apps successfully get alerts from Grafana.